Exemplo n.º 1
0
 this.compileTemplate = function (path) {
     var src = loadTemplate(path);
     
     if (src) {
         return TEMPLATE.compile(this.preprocessTemplate(src), this.compileOptions);
     } else {
         throw new Error("Template '" + path + "' not found");
     }   
 }    
Exemplo n.º 2
0
    this.preprocessTemplate = function (src) {
        var st, stSrc, stPath;

        if (stPath = tpp.getTemplatePath(src)) {
            // The template defines values for a super-template.
            if (stSrc = loadTemplate(stPath)) {
                stSrc = tpp.expandIncludes(stSrc, loadTemplate);
                st = TEMPLATE.compile(stSrc);
                src = tpp.expandIncludes(src, loadTemplate);
                var data = tpp.extractData(src);
                src = st(Hash.update(data, options.tppData || {}));
                return src;
            } else {
                throw new Error("Template '" + stPath + "' not found");
            }
        } else {
            src = tpp.expandIncludes(src, loadTemplate);
            return src;
        }
    }