當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ejs.compile函數代碼示例

本文整理匯總了TypeScript中ejs.compile函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript compile函數的具體用法?TypeScript compile怎麽用?TypeScript compile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了compile函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getCompiledTemplate

/**
 * Wrapper function for boilerplate of compiling templates
 * Also Caches the Templates to avoid reloading and recompiling
 * */
function getCompiledTemplate(templatePath: string): any {
    if (!this.compiledTemplates)
        this.compiledTemplates = {};
    if (!this.compiledTemplates.hasOwnProperty(templatePath))
        this.compiledTemplates[templatePath] = ejs.compile(readFile(templatePath));
    return this.compiledTemplates[templatePath];
}
開發者ID:PlayFab,項目名稱:SDKGenerator,代碼行數:11,代碼來源:generate.ts

示例2: updateFile

function updateFile(tree, pathname, aggData, errorMessages) {
    /*
    let compName = angNameToClassName(path.basename(pathname, ".md"));
    let classRef = aggData.projData.findReflectionByName(compName);

    if (!classRef) {
        // A doc file with no corresponding class (eg, Document Library Model).
        return false;
    }

    let compData = new ComponentInfo(classRef);
    */

    let className = ngNameToClassName(path.basename(pathname, ".md"), nameExceptions);
    let classTypeMatch = className.match(/component|directive|service/i);
    let compData = aggData.classInfo[className];

    if (classTypeMatch && compData) {
        let classType = classTypeMatch[0].toLowerCase();

        // Copy docs back from the .md file when the JSDocs are empty.
        let inputMD = getPropDocsFromMD(tree, "Properties", 3);
        let outputMD = getPropDocsFromMD(tree, "Events", 2);
        updatePropDocsFromMD(compData, inputMD, outputMD, errorMessages);

        if (classType === "service") {
            let methodMD = getMethodDocsFromMD(tree);
            updateMethodDocsFromMD(compData, methodMD, errorMessages);
        }

        let templateName = path.resolve(templateFolder, classType + ".ejs");
        let templateSource = fs.readFileSync(templateName, "utf8");
        let template = ejs.compile(templateSource);

        let mdText = template(compData);
        mdText = mdText.replace(/^ +\|/mg, "|");

        let newSection = remark().parse(mdText.trim()).children;

        replaceSection(tree, "Class members", (before, section, after) => {
            newSection.unshift(before);
            newSection.push(after);
            return newSection;
        });

        compData.errors.forEach(err => {
            errorMessages.push(err);
        })
    }

    return true;
}
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:52,代碼來源:tsInfo.ts

示例3: processDocs

export function processDocs(mdCache, aggData, _errorMessages) {
    let docset: MQ.Docset = new MQ.Docset(mdCache);

    let templateFilePath = path.resolve(__dirname, '..', 'templates', 'gqIndex.ejs');
    let templateSource = fs.readFileSync(templateFilePath, 'utf8');
    let template = ejs.compile(templateSource);

    let indexFilePath = path.resolve(aggData['rootFolder'], 'docs', 'README.md');
    let indexFileText = fs.readFileSync(indexFilePath, 'utf8');
    let indexMD = remark()
    .use(frontMatter, ["yaml"])
    .parse(indexFileText);

    let schema = buildSchema(MQ.schema);

    libNamesList.forEach(libName => {
        graphql(schema, query, docset, null, {'libName': libName})
        .then((response) => {
            if (!response['data']) {
                console.log(JSON.stringify(response));
            } else {
                //console.log(template(response['data']));
                let newSection = remark().parse(template(response['data'])).children;

                replaceZone(indexMD, libName, (start, _oldZone, end) => {
                    newSection.unshift(start);
                    newSection.push(end);
                    return newSection;
                });

                let outText = remark()
                .use(frontMatter, {type: 'yaml', fence: '---'})
                .data("settings", {paddedTable: false, gfm: false})
                .stringify(indexMD);

                fs.writeFileSync(indexFilePath, outText);
            }
        });
    });

    
}
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:42,代碼來源:gqIndex.ts

示例4: aggPhase

function aggPhase(aggData) {
    let indexDocData = getIndexDocData();

    let templateName = path.resolve(templateFolder, "tutIndex.ejs");
    let templateSource = fs.readFileSync(templateName, "utf8");
    let template = ejs.compile(templateSource);

    let mdText = template(indexDocData);
    mdText = mdText.replace(/^ +\|/mg, "|");

    let newSection = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(mdText.trim()).children;

    let tutIndexFile = path.resolve(tutFolder, "README.md");
    let tutIndexText = fs.readFileSync(tutIndexFile, "utf8");
    let tutIndexMD = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(tutIndexText);

    replaceSection(tutIndexMD, "Tutorials", (before, section, after) => {
        newSection.unshift(before);
        newSection.push(after);
        return newSection;
    });

    fs.writeFileSync(tutIndexFile, remark().use(frontMatter, {type: 'yaml', fence: '---'}).data("settings", {paddedTable: false, gfm: false}).stringify(tutIndexMD));
}
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:24,代碼來源:tutorialIndex.ts

示例5: return

 return (file: IFileObj) => ({ name: file.name, contents: compile(file.contents)(data) });
開發者ID:overlandjs,項目名稱:ltd,代碼行數:1,代碼來源:template.ts


注:本文中的ejs.compile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。