mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-05 05:27:59 +08:00
adjust ssr API so that user can provide server-side implementations for custom directives
This commit is contained in:
parent
3c7aafa17b
commit
4191f251af
@ -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
|
||||||
|
@ -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
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
@ -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 => {
|
||||||
|
@ -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', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user