Browse Source

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

dev
Evan You 9 years ago
parent
commit
4191f251af
  1. 4
      circle.yml
  2. 31
      src/entries/web-server-renderer.js
  3. 3
      test/ssr/ssr.stream.spec.js
  4. 5
      test/ssr/ssr.sync.spec.js

4
circle.yml

@ -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

31
src/entries/web-server-renderer.js

@ -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, attrs,
modules: [ klass,
attrs, style
klass, ]
style
], const baseDirectives = {
directives: { 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
})
}

3
test/ssr/ssr.stream.spec.js

@ -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 => {

5
test/ssr/ssr.sync.spec.js

@ -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…
Cancel
Save