当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.template函数代码示例

本文整理汇总了TypeScript中lodash.template函数的典型用法代码示例。如果您正苦于以下问题:TypeScript template函数的具体用法?TypeScript template怎么用?TypeScript template使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了template函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Buffer

 .spread( (content: string, outerContent : string) => {
   try {
     log.info('Compile composite view %s in %s',templateFilename,layoutFilename);
     var innerContent = new Buffer( _.template(content)(viewData), 'utf-8' );
     var fullContent = new Buffer( _.template(outerContent)( { page: innerContent, name: viewData.Name, data: viewData.data }), 'utf-8');
     laterAct.resolve( new relaxjs.Embodiment( 'text/html', 200, fullContent ));
   }
   catch( err ) {
     log.error( err );
     laterAct.reject( emitCompileViewError(content,err, templateFilename +' in '+ layoutFilename) );
   }
 })
开发者ID:micurs,项目名称:relaxjs,代码行数:12,代码来源:internals.ts

示例2: createPlatformTests

  function createPlatformTests() {
    let platforms = [
      'android',
      'ios',
      'windows'
    ];

    let testTemplate = template(readFileSync(`${SCRIPTS_ROOT}/${E2E_NAME}/e2e.template.js`).toString());

    return obj(function (file, enc, next) {
      let self = this;

      let relativePath = dirname(file.path.replace(/^.*?src(\/|\\)components(\/|\\)/, ''));
      relativePath = relativePath.replace('/test/', '/');

      let contents = file.contents.toString();
      platforms.forEach(function (platform) {
        let platformContents = testTemplate({
          contents: contents,
          buildConfig: buildConfig,
          relativePath: relativePath,
          platform: platform
        });
        self.push(new VinylFile({
          base: file.base,
          contents: new Buffer(platformContents),
          path: file.path.replace(/e2e.js$/, platform + '.e2e.js')
        }));
      });
      next();
    });
  }
开发者ID:fsdn,项目名称:ionic,代码行数:32,代码来源:e2e.dev.ts

示例3: _generateAndSave

  private _generateAndSave(filePath: string): void {
    let splitted = filePath.split(path.sep);
    let part = splitted.filter(p => {
      return splitted.indexOf(p) > splitted.indexOf(this.model);
    }).join('/');
    let to;
    if (this.model !== 'project') {
      to = path.join('src', 'app', `${this.model}s`,
        this.name, path.basename(part).replace(/name/, this.name));
    } else {
      to = part;
    }

    try {
      if (!dir.isDir(filePath)) {
        let contents = fse.readFileSync(filePath, 'utf8');
        let template = _.template(contents, { variable: 'data' });
        fse.outputFileSync(to, template(this.data), 'utf8');
        console.log(`  ${chalk.green('create')} ${to}`);
      } else {
        if (!helper.existsSync(to)) {
          fse.mkdirsSync(to);
        }
      }
    } catch (e) {
      throw new Error(e);
    }
  }
开发者ID:jkuri,项目名称:ng2-cli,代码行数:28,代码来源:blueprint.ts

示例4: makeCollapsible

export function makeCollapsible(document: Document,
                                kind: string,
                                headingId: string,
                                collapseId: string,
                                additional: AdditionalClasses = {}):
Collapsible {
  let additionalGroupClasses = additional.group;
  let additionalPanelClasses = additional.panel;
  let additionalToggleClasses = additional.toggle;

  additionalPanelClasses =
    additionalPanelClasses !== undefined ? ` ${additionalPanelClasses}` : "";

  additionalGroupClasses =
    additionalGroupClasses !== undefined ? ` ${additionalGroupClasses}` : "";

  additionalToggleClasses =
    additionalToggleClasses !== undefined ? ` ${additionalToggleClasses}` : "";

  const el = domutil.htmlToElements(
    _.template(collapsibleTemplate)({
      kind: kind,
      group_classes: additionalGroupClasses,
      panel_classes: additionalPanelClasses,
      toggle_classes: additionalToggleClasses,
      heading_id: headingId,
      collapse_id: collapseId,
    }), document)[0] as HTMLElement;

  return {
    group: el,
    heading: el.getElementsByTagName("a")[0],
    content: el.getElementsByClassName("panel-body")[0] as HTMLElement,
  };
}
开发者ID:mangalam-research,项目名称:btw,代码行数:35,代码来源:btw-util.ts

示例5: function

			sails.router.bind(route, function (req: any, res: any, next: Function) {

				let protocol: any = _.startsWith(swagger.host, 'http') ? '' : 'http://';
				let targetUrlTemplate: any = protocol + swagger.host + ( swagger.basePath || '' ) + path;
				let templateFn: any = _.template(targetUrlTemplate, {
					interpolate: /{([\s\S]+?)}/g
				});

				let params: any = req.allParams();

				let targetUrl: any = templateFn(params);

				let headers: any = req.headers;

				_.unset(headers, 'cookie');
				_.unset(headers, 'host');
				_.unset(headers, 'user-agent');
				_.unset(headers, 'referer');

				let reqOut: any = {
					url: targetUrl,
					method: vertex,
					body: ( req.body || null ),
					qs: req.transport != 'socket.io' ? req.query : req.body,
					json: true,
					headers: headers
				};

				let $request: any = sails.$request(req.session) || request;
				$request(reqOut, function (err: Error, message: any, body: any): void {

					console.log('*************************');
					console.log('' + vertex + ' ' + targetUrl);
					console.log('-------------------------');
					console.dir(headers);
					console.log('=========================');
					console.dir(body);

					if (params && body && !params.id && !_.isArray(body)) {
						body.id = body.id || uuid.v4();
						body = [body];
					}
					else if (_.isArray(body)) {
						_.each(body, function (item: any) {
							item.id = item.id || uuid.v4();
						});
					}

					if (!err) {
						res
							.status(message.statusCode)
							.send(body);
					}
					else {
						res.serverError(err);
					}
				})
			})
开发者ID:pmoelgaard,项目名称:nx-sails-swagger-api,代码行数:58,代码来源:index.ts

示例6: map

  const criteriaValues = map(criteria, (rawValue, key) => {
    let value = rawValue
    if (typeof rawValue === 'string') {
      value = template(rawValue)(userContext)
      if (/^\d+$/.test(value)) value = Number.parseInt(value)
    }

    return [key, value]
  })
开发者ID:patrickhulce,项目名称:klay,代码行数:9,代码来源:grants.ts

示例7: it

 it("can make a new instance", async () => {
   const story = new StoryModel();
   const message = new MessageModel();
   message.name = "TESTMESSAGE";
   message.text = "This is the text of our message";
   message.story = story._id;
   message.compiledSource = _.template(message.text).source;
   message.messagesLoaded = [];
   await message.validate();
 });
开发者ID:trflagg,项目名称:bargie,代码行数:10,代码来源:message.ts

示例8: exec

wrap<void>(function* (
  dfpath: string,
  tag: string,
  config: BuildConfig,
  opts: BuildOptions) {

  const cmd = opts.useCache ?
    `docker build -f ${relative(process.cwd(), dfpath)} -t ${tag} .` :
    `docker build -f ${relative(process.cwd(), dfpath)} -t ${tag} --no-cache .`;
  yield exec(cmd);
  if (config.afterEach && !opts.skipAfterEach) {
    yield exec(template(config.afterEach)({ tag }));
  }
});
开发者ID:d6u,项目名称:docker-build-layers,代码行数:14,代码来源:Util.ts

示例9: it

 it('should assign unique labels', function () {
   scope.data = {text: null};
   var template = _.template('<formfield type="<%= type %>" label="thelabel" model="data" model-var="text"></formfield>');
   var field, input, label;
   _.each(_.range(5), function (item, index) {
     field = template({type: index > 2 ? 'number' : 'text'});
     kaanna(field);
     input = element.find('input');
     label = element.find('label');
     $timeout.flush();
     expect(input.length).toBe(1);
     expect(label.length).toBe(1);
     expect(input.attr('id')).toBe('thelabel-' + index);
     expect(label.attr('for')).toBe('thelabel-' + index);
   });
 });
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:16,代码来源:formfield.ts


注:本文中的lodash.template函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。