File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -149,11 +149,16 @@ function actuallyCompile (
149
149
// transpile code with vue-template-es2015-compiler, which is a forked
150
150
// version of Buble that applies ES2015 transforms + stripping `with` usage
151
151
let code = transpile (
152
- `var render = ${ toFunction ( render ) } \n` +
153
- `var staticRenderFns = [${ staticRenderFns . map ( toFunction ) } ]` ,
152
+ `var __render__ = ${ toFunction ( render ) } \n` +
153
+ `var __staticRenderFns__ = [${ staticRenderFns . map ( toFunction ) } ]` ,
154
154
finalTranspileOptions
155
155
) + `\n`
156
156
157
+ // #23 we use __render__ to avoid `render` not being prefixed by the
158
+ // transpiler when stripping with, but revert it back to `render` to
159
+ // maintain backwards compat
160
+ code = code . replace ( / \s _ _ ( r e n d e r | s t a t i c R e n d e r F n s ) _ _ \s / g, ' $1 ' )
161
+
157
162
if ( ! isProduction ) {
158
163
// mark with stripped (this enables Vue to use correct runtime proxy
159
164
// detection)
Original file line number Diff line number Diff line change @@ -2,6 +2,26 @@ import { parse } from '../lib/parse'
2
2
import { compileTemplate } from '../lib/compileTemplate'
3
3
import * as compiler from 'vue-template-compiler'
4
4
5
+ test ( 'should work' , ( ) => {
6
+ const source = `<div><p>{{ render }}</p></div>`
7
+
8
+ const result = compileTemplate ( {
9
+ filename : 'example.vue' ,
10
+ source,
11
+ compiler : compiler
12
+ } )
13
+
14
+ expect ( result . errors . length ) . toBe ( 0 )
15
+ expect ( result . source ) . toBe ( source )
16
+ // should expose render fns
17
+ expect ( result . code ) . toMatch ( `var render = function` )
18
+ expect ( result . code ) . toMatch ( `var staticRenderFns = []` )
19
+ // should mark with stripped
20
+ expect ( result . code ) . toMatch ( `render._withStripped = true` )
21
+ // should prefix bindings
22
+ expect ( result . code ) . toMatch ( `_vm.render` )
23
+ } )
24
+
5
25
test ( 'preprocess pug' , ( ) => {
6
26
const template = parse ( {
7
27
source :
You can’t perform that action at this time.
0 commit comments