forked from vuejs/vue
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
50 lines (43 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* @flow */
import { genStaticKeys } from 'shared/util'
import { createCompiler } from 'compiler/index'
import modules from './modules/index'
import directives from './directives/index'
import {
isUnaryTag,
mustUseProp,
isReservedTag,
canBeLeftOpenTag,
getTagNamespace
} from '../util/index'
export const baseOptions: CompilerOptions = {
modules,
directives,
isUnaryTag,
mustUseProp,
canBeLeftOpenTag,
isReservedTag,
getTagNamespace,
preserveWhitespace: false,
recyclable: false,
staticKeys: genStaticKeys(modules)
}
const compiler = createCompiler(baseOptions)
export function compile (
template: string,
options?: CompilerOptions
): CompiledResult {
let generateAltRender = false
if (options && options.recyclable === true) {
generateAltRender = true
options.recyclable = false
}
const result = compiler.compile(template, options)
// generate @render function for <recycle-list>
if (options && generateAltRender) {
options.recyclable = true
const { render } = compiler.compile(template, options)
result['@render'] = render
}
return result
}