How to use the common-tags.TemplateTag function in common-tags

To help you get started, we’ve selected a few common-tags examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / common-tags / common-tags-tests.ts View on Github external
new commonTags.TemplateTag(commonTags.trimResultTransformer());
new commonTags.TemplateTag(commonTags.trimResultTransformer('left'));
new commonTags.TemplateTag(commonTags.trimResultTransformer('right'));

new commonTags.TemplateTag(commonTags.stripIndentTransformer());
new commonTags.TemplateTag(commonTags.stripIndentTransformer('initial'));
new commonTags.TemplateTag(commonTags.stripIndentTransformer('all'));

new commonTags.TemplateTag(commonTags.replaceResultTransformer('foo', 'bar'));

new commonTags.TemplateTag(commonTags.inlineArrayTransformer());
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({}));
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({separator: 'foo'}));
new commonTags.TemplateTag(commonTags.inlineArrayTransformer({conjunction: 'bar'}));

new commonTags.TemplateTag(commonTags.splitStringTransformer('foo'));
github doczjs / docz / core / docz-core / src / utils / parse-html.ts View on Github external
const generateRawTags = (items: any[] = []) => {
  if (typeof items === 'string' || items instanceof String) return items
  return items.map(item => item).join('')
}

const getHtmlFilepath = (indexHtml: string | undefined) =>
  indexHtml
    ? path.resolve(paths.root, indexHtml)
    : fromTemplates('index.tpl.html')

const getPublicUrl = (config: Config, dev: boolean): string => {
  const prefix = config.base === '/' ? '' : config.base
  return dev ? prefix : `${prefix}/public`
}

const emptyLineTrim = new ctags.TemplateTag(
  ctags.replaceResultTransformer(/^\s*[\r\n]/gm, ''),
  ctags.trimResultTransformer
)

export const htmlTemplate = async (indexHtml: string | undefined) =>
  compiled(getHtmlFilepath(indexHtml), {
    minimize: false,
    escape: false,
  })

interface ParseHtmlParams {
  config: Config
  ctx: Record
  dev: boolean
  template: (props: Record) => string
}
github thebespokepixel / trucolor / src / lib / colour.js View on Github external
msat: 'red desaturate 60',
	mlight: 'rgb(255,255,255) darken 25',
	bright: 'rgb(255,255,255)',
	bob: 'black lighten 50 saturate 50 spin 180',
	ul: 'underline',
	invert: 'invert',
	exBackground: 'background dark red',
	exBold: 'bold yellow',
	exFaint: 'faint yellow',
	exItalic: 'italic #33FF33',
	exInvert: 'invert #7B00B1',
	exUnderline: 'underline #fff',
	exBlink: 'blink orange'
}))

export const colorReplacer = new TemplateTag(
	replaceSubstitutionTransformer(
		/([a-zA-Z]+?)[:/|](.+)/,
		(match, colorName, content) => `${clr[colorName]}${content}${clr[colorName].out}`
	)
)

export function spectrum(width, char) {
	if (terminalFeatures.color.has16m) {
		return _.map(new Array(width), (val, col) => {
			const scos = Math.cos((col / width) * (Math.PI / 2))
			const ssin = Math.sin((col / width) * (Math.PI))
			const red = (scos > 0) ? Math.floor(scos * 255) : 0
			const green = (ssin > 0) ? Math.floor(ssin * 255) : 0
			const blue = (scos > 0) ? Math.floor((1 - scos) * 255) : 0
			return `\u001B[38;2;${red};${green};${blue}m${char}`
		}).join('')