adjust ssr API so that user can provide server-side implementations for custom directives

This commit is contained in:
Evan You 2016-04-26 00:42:49 -04:00
parent 3c7aafa17b
commit 4191f251af
4 changed files with 29 additions and 14 deletions

View File

@ -9,4 +9,6 @@ general:
test: test:
override: override:
- npm run test:cover # only run unit tets for now before we setup SauceLabs - npm run lint
- npm run test:cover # only run unit tests in Phantom for now before we setup SauceLabs
- npm run test:ssr

View File

@ -5,14 +5,23 @@ import style from 'web/server/modules/style'
import show from 'web/server/directives/show' import show from 'web/server/directives/show'
import { isUnaryTag } from 'web/util/index' import { isUnaryTag } from 'web/util/index'
export default createRenderer({ const modules = [
isUnaryTag,
modules: [
attrs, attrs,
klass, klass,
style style
], ]
directives: {
const baseDirectives = {
show show
} }
export default function publicCreateRenderer (options = {}) {
// user can provide server-side implementations for custom directives
// when creating the renderer.
const directives = Object.assign(baseDirectives, options.directives)
return createRenderer({
isUnaryTag,
modules,
directives
}) })
}

View File

@ -1,6 +1,7 @@
import Vue from '../../dist/vue.common.js' import Vue from '../../dist/vue.common.js'
import { compileToFunctions } from '../../dist/compiler.common.js' import { compileToFunctions } from '../../dist/compiler.common.js'
import { renderToStream } from '../../dist/server-renderer.js' import createRenderer from '../../dist/server-renderer.js'
const { renderToStream } = createRenderer()
describe('SSR: renderToStream', () => { describe('SSR: renderToStream', () => {
it('should render to a stream', done => { it('should render to a stream', done => {

View File

@ -1,6 +1,9 @@
import Vue from '../../dist/vue.common.js' import Vue from '../../dist/vue.common.js'
import { compileToFunctions } from '../../dist/compiler.common.js' import { compileToFunctions } from '../../dist/compiler.common.js'
import { renderToString } from '../../dist/server-renderer.js' import createRenderer from '../../dist/server-renderer.js'
const { renderToString } = createRenderer()
// TODO: test custom server-side directives
describe('SSR: renderToString', () => { describe('SSR: renderToString', () => {
it('static attributes', () => { it('static attributes', () => {