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


TypeScript handlebars.compile函數代碼示例

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


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

示例1: populateTemplate

	private populateTemplate(mailData: Mailer): Promise<Mailer> {
		let deferred = Q.defer();
		mailData.message = Handlebars.compile(mailData.template.html)(mailData.templateData);
		mailData.template.subject = Handlebars.compile(mailData.template.subject)(mailData.templateData);
		deferred.resolve(mailData);
		return deferred.promise;
	}
開發者ID:dangle0118,項目名稱:mailing,代碼行數:7,代碼來源:mailer.ts

示例2: getTemplateFunction

  getTemplateFunction() {
    // Template compilation
    // --------------------

    // This demo uses Handlebars templates to render views.
    // The template is loaded with Require.JS and stored as string on
    // the view prototype. On rendering, it is compiled on the
    // client-side. The compiled template function replaces the string
    // on the view prototype.
    //
    // In the end you might want to precompile the templates to JavaScript
    // functions on the server-side and just load the JavaScript code.
    // Several precompilers create a global JST hash which stores the
    // template functions. You can get the function by the template name:
    //
    // templateFunc = JST[@templateName];
    let template = this.template;
    let templateFunction: Function;

    if (typeof template === 'string') {
      // Compile the template string to a function and save it
      // on the prototype. This is a workaround since an instance
      // shouldn't change its prototype normally.

      templateFunction = Handlebars.compile(template);
      this.template = templateFunction;
    } else if (typeof template === 'function') {
      templateFunction = template;
    }

    return templateFunction;
  }
開發者ID:fafnirical,項目名稱:test--chaplin,代碼行數:32,代碼來源:view.ts

示例3: exportTexturePoolViaHandlebarsTemplate

function exportTexturePoolViaHandlebarsTemplate(
  folderRootTo: string,
  templateFolderAndFile: string,
  data: any,
) {
  let text = fs.readFileSync(templateFolderAndFile, 'utf8');
  if (text && text.length > 0) {
    text = text.replace(/\r/g, '');

    const lines = text.split('\n');
    if (lines.length > 1 && lines[0]) {
      const resultFile = path.resolve(folderRootTo, lines[0]);
      text = lines.slice(1).join('\n');

      console.log(`${templateFolderAndFile} => ${resultFile}`);
      const template = handlebars.compile(text);
      if (template) {
        fs.ensureDirSync(path.dirname(resultFile));
        fs.writeFileSync(resultFile, template(data));
      } else {
        console.log('template error in ' + resultFile);
      }
    }
  }
}
開發者ID:igor-bezkrovny,項目名稱:texturer,代碼行數:25,代碼來源:meta.ts

示例4:

Marionette.TemplateCache.prototype.compileTemplate = (rawTemplate: any): any => {
  if (_.isFunction(rawTemplate)) {
    return rawTemplate;
  } else {
    return Handlebars.compile(rawTemplate);
  }
};
開發者ID:fafnirical,項目名稱:test--marionette,代碼行數:7,代碼來源:view.ts

示例5: _compileTemplate

    private _compileTemplate(templatePath: string, data: Object) {
        const templateFileName = path.join(process.cwd(), templatePath);
        const templateFile = fs.readFileSync(templateFileName, 'UTF-8');

        const templateFunc: Function = handlebars.compile(templateFile);
        return templateFunc(data);
    }
開發者ID:Uter1007,項目名稱:sumobase.core,代碼行數:7,代碼來源:mail.service.ts

示例6: getFilesFrom

        .then((data) => {
            const [file, pack, meta] = data;
            const connectionTypes = ['mainnet', 'testnet'];

            if (!param.scripts) {
                const sourceFiles = getFilesFrom(join(__dirname, '../src'), '.js', function (name, path) {
                    return !name.includes('.spec') && !path.includes('/test/');
                });
                param.scripts = meta.vendors.map((i) => join(__dirname, '..', i)).concat(sourceFiles);
                param.scripts.push(join(__dirname, '../loginDaemon.js'));
            }

            if (!param.styles) {
                param.styles = meta.stylesheets.map((i) => join(__dirname, '..', i)).concat(getFilesFrom(join(__dirname, '../src'), '.less'));
            }

            const networks = connectionTypes.reduce((result, item) => {
                result[item] = meta.configurations[item];
                return result;
            }, Object.create(null));

            return compile(file)({
                pack: pack,
                domain: meta.domain,
                build: {
                    type: 'web'
                },
                network: networks[param.connection]
            });
        })
開發者ID:beregovoy68,項目名稱:WavesGUI,代碼行數:30,代碼來源:utils.ts

示例7: function

        handler: function(request, reply) {
            let paths = getPaths(server, baseUri, filter);
            let source = fs.readFileSync(__dirname + '/sitemap.xml.hbs', 'utf8');

            let template = handlebars.compile(source);
            reply(template({paths: paths}))
                .type('application/xml');
        },
開發者ID:csgpro,項目名稱:csgpro.com,代碼行數:8,代碼來源:index.ts

示例8: subHandle

function subHandle(fullPath: string, args: any) {
  wd = path.dirname(fullPath);
  let tmpl = fs.readFileSync(fullPath, 'utf8');

  var template = hbs.compile(tmpl.toString());
  var result = template(args);
  return result;
}
開發者ID:spion,項目名稱:handlebars-cmd,代碼行數:8,代碼來源:processor.ts

示例9: loadTemplate

export function loadTemplate(name: string): Template {

  const template = handlebars.compile(
    fs.readFileSync(__dirname + '/../templates/' + name + '.hbs', 'utf-8')
  );

  return template;

}
開發者ID:evert,項目名稱:a12n-server,代碼行數:9,代碼來源:templates.ts

示例10: function

      tmpl: function(resolver, templateString, refObj, wire) {
        var template = handlebars.compile(templateString);

        // get the entire wire context
        wire.createChild({}).
          // render the template with the context
          then(template).
          // resolve with the rendered template
          then(resolver.resolve).
          catch(resolver.reject);
      }
開發者ID:aerisweather,項目名稱:PushButton,代碼行數:11,代碼來源:tmpl.ts


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