• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript lodash.template类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: minify

    return es.map(function(file: any, callback: (err: any, htmlMinifierfile: any) => void) {
        var template = '$templateCache.put("<%= url %>","<%= contents %>");';
        var url;

        file.path = path.normalize(file.path);

        if(typeof options.path === 'function') {
            url = path.join(options.path(file.path, file.base));
        } else {
            url = path.join(file.path);
            url = url.replace(file.base, '');
        };

        if (process.platform === 'win32') {
            url = url.replace(/\\/g, '/');
        }

        let contents = file.contents.toString();

        if(options.htmlMinifier) {
            contents = minify(contents, options.htmlMinifier);
        }

        contents = require('js-string-escape')(contents);

        file.contents = Buffer.from(lodashTemplate(template)({
            url: url,
            contents: contents,
            file: file
        }), 'utf8');

        callback(null, file);
    });
开发者ID:VictorQueiroz,项目名称:gulp-ng-templates,代码行数:33,代码来源:index.ts


示例2: create

	private async create(url: string, size: string, options: Options): Promise<Screenshot> {
		const basename = path.isAbsolute(url) ? path.basename(url) : url;

		let hash = parseUrl(url).hash || '';
		// Strip empty hash fragments: `#` `#/` `#!/`
		if (/^#!?\/?$/.test(hash)) {
			hash = '';
		}

		const [width, height] = size.split('x');

		const filenameTemplate = template(`${options.filename}.${options.format}`);

		const now = Date.now();
		let filename = filenameTemplate({
			crop: options.crop ? '-cropped' : '',
			date: dateFns.format(now, 'YYYY-MM-DD'),
			time: dateFns.format(now, 'HH-mm-ss'),
			size,
			width,
			height,
			url: `${filenamifyUrl(basename)}${filenamify(hash)}`
		});

		if (options.incrementalName) {
			filename = unusedFilename.sync(filename);
		}

		// TODO: Type this using the `capture-website` types
		const finalOptions: any = {
			width: Number(width),
			height: Number(height),
			delay: options.delay,
			timeout: options.timeout,
			fullPage: !options.crop,
			styles: options.css && [options.css],
			scripts: options.script && [options.script],
			cookies: options.cookies, // TODO: Support string cookies in capture-website
			element: options.selector,
			hideElements: options.hide,
			scaleFactor: options.scale === undefined ? 1 : options.scale,
			type: options.format === 'jpg' ? 'jpeg' : 'png',
			userAgent: options.userAgent,
			headers: options.headers
		};

		if (options.username && options.password) {
			finalOptions.authentication = {
				username: options.username,
				password: options.password
			};
		}

		const screenshot = await captureWebsite.buffer(url, finalOptions) as any;
		screenshot.filename = filename;
		return screenshot;
	}
开发者ID:sindresorhus,项目名称:pageres,代码行数:57,代码来源:index.ts


示例3: template

 Object.keys(obj).forEach((objKey) => {
   if (typeof obj[objKey] === 'object' && obj !== null) {
     template(obj[objKey]);
   } else if (typeof obj[objKey] === 'string') {
     obj[objKey] = _template(obj[objKey])(templateObj); // eslint-disable-line
     if (obj[objKey].startsWith('require:')) {
       obj[objKey] = require(path.resolve(dir, obj[objKey].substr(8))); // eslint-disable-line
     }
   }
 });
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:10,代码来源:forge-config.ts


示例4: createDocumentFootnotes

export function createDocumentFootnotes(settings: Settings): RawFootnote[] {
  const { anchorParentSelector, buttonTemplate, numberResetSelector } = settings
  const offset = parseInt(getLastFootnoteId(), 10) + 1

  return findFootnoteLinks(settings)
    .map(findFootnoteBody(settings))
    .filter(isDefined)
    .map(hideOriginalFootnote)
    .map(templateData(anchorParentSelector, offset))
    .map(numberResetSelector ? resetNumbers(numberResetSelector) : i => i)
    .map(addButton(template(buttonTemplate)))
}
开发者ID:goblindegook,项目名称:littlefoot,代码行数:12,代码来源:setup.ts


示例5: template

const runCommand = (
  command: string,
  options: Required<Options>,
  file: Vinyl | null
): Promise<void> => {
  const context = { file, ...options.templateData }
  command = template(command)(context)

  if (options.verbose) {
    fancyLog(`${PLUGIN_NAME}:`, chalk.cyan(command))
  }

  const child = spawn(command, {
    env: options.env,
    cwd: template(options.cwd)(context),
    shell: options.shell,
    stdio: options.quiet ? 'ignore' : 'inherit'
  })

  return new Promise((resolve, reject) => {
    child.on('exit', code => {
      if (code === 0 || options.ignoreErrors) {
        return resolve()
      }

      const context = {
        command,
        file,
        error: { code },
        ...options.templateData
      }

      const message = template(options.errorMessage)(context)

      reject(new PluginError(PLUGIN_NAME, message))
    })
  })
}
开发者ID:sun-zheng-an,项目名称:gulp-shell,代码行数:38,代码来源:index.ts


示例6: insertPopover

function insertPopover(
  button: HTMLElement,
  contentTemplate: string,
  data: TemplateData
) {
  const render = template(contentTemplate)
  button.insertAdjacentHTML('afterend', render(data))
  const popover = button.nextElementSibling as HTMLElement
  const content = findPopoverContent(popover)
  popover.setAttribute(FOOTNOTE_MAX_HEIGHT, `${getMaxHeight(content)}`)
  popover.style.maxWidth = `${document.body.clientWidth}px`
  bindContentScrollHandler(content)
  return popover
}
开发者ID:goblindegook,项目名称:littlefoot,代码行数:14,代码来源:footnote.ts


示例7: resolve

    child.on('exit', code => {
      if (code === 0 || options.ignoreErrors) {
        return resolve()
      }

      const context = {
        command,
        file,
        error: { code },
        ...options.templateData
      }

      const message = template(options.errorMessage)(context)

      reject(new PluginError(PLUGIN_NAME, message))
    })
开发者ID:sun-zheng-an,项目名称:gulp-shell,代码行数:16,代码来源:index.ts


示例8: require

        result += placeholders[i]
            .replace(/&/g, '&amp;')
            .replace(/"/g, '&quot;')
            .replace(/'/g, '&#39;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;');
    }

    // add the last literal
    result += literals[literals.length - 1];
    return result;
}

var lotmpl = require( 'lodash.template' );

var emailTmp = lotmpl( fs.readFileSync( "book-sample-request.pt.html", "utf8" ) );

function escapeFormField( field: string ): string {
  return field
      .replace(/&/g, '&amp;')
      .replace(/"/g, '&quot;')
      .replace(/'/g, '&#39;')
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;');
}

function sendMail( template, info, cb ) {
  var auth = config.subscribe.auth;

  // setup e-mail data with unicode symbols
  var mailOptions = {
开发者ID:essential-cryptography,项目名称:essentialcryptography.com,代码行数:31,代码来源:server.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.throttle类代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.merge类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap