當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。