|
|
@@ -17,14 +17,20 @@ const baseOptions = {
|
|
|
getTagNamespace
|
|
|
}
|
|
|
|
|
|
-export function compile (template: string, options: Object): Object {
|
|
|
+export function compile (
|
|
|
+ template: string,
|
|
|
+ options: Object
|
|
|
+): { render: string, staticRenderFns: Array<string> } {
|
|
|
options = options
|
|
|
? extend(extend({}, baseOptions), options)
|
|
|
: baseOptions
|
|
|
return baseCompile(template, options)
|
|
|
}
|
|
|
|
|
|
-export function compileToFunctions (template: string, options: Object = {}): Object {
|
|
|
+export function compileToFunctions (
|
|
|
+ template: string,
|
|
|
+ options: Object = {}
|
|
|
+): { render: Function, staticRenderFns: Array<Function> } {
|
|
|
options.preserveWhitespace = options.preserveWhitespace !== false
|
|
|
const cache = options.preserveWhitespace ? cache1 : cache2
|
|
|
if (cache[template]) {
|
|
|
@@ -34,11 +40,9 @@ export function compileToFunctions (template: string, options: Object = {}): Obj
|
|
|
const compiled = compile(template, options)
|
|
|
res.render = new Function(compiled.render)
|
|
|
const l: number = compiled.staticRenderFns.length
|
|
|
- if (l) {
|
|
|
- res.staticRenderFns = new Array(l)
|
|
|
- for (let i = 0; i < l; i++) {
|
|
|
- res.staticRenderFns[i] = new Function(compiled.staticRenderFns[i])
|
|
|
- }
|
|
|
+ res.staticRenderFns = new Array(l)
|
|
|
+ for (let i = 0; i < l; i++) {
|
|
|
+ res.staticRenderFns[i] = new Function(compiled.staticRenderFns[i])
|
|
|
}
|
|
|
return (cache[template] = res)
|
|
|
}
|