Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new commonTags.TemplateTag({
onSubstitution: substitution => `${substitution}!`,
onEndResult: endResult => `${endResult}!`
});
/* Tests Built-in Transformers */
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'));
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
}