Sha256: 066e240afbdbc1c4d9ff584f327013984448721e1199e130b8489a6107d43ed3
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
function buildProgram(b, content, loc) { return b.program([buildStatement(b, content, loc)], undefined, loc); } function buildStatement(b, content, loc) { switch (content.type) { case 'PathExpression': return b.mustache(content, undefined, undefined, undefined, loc); case 'SubExpression': return b.mustache(content.path, content.params, content.hash, undefined, loc); // The default case handles literals. default: return b.text(`${content.value}`, loc); } } function unsafeHtml(b, expr) { return b.sexpr('-html-safe', [expr]); } export default function transformInlineLinkTo(env) { let { builders: b } = env.syntax; return { name: 'transform-inline-link-to', visitor: { MustacheStatement(node) { if (node.path.original === 'link-to') { let content = node.escaped ? node.params[0] : unsafeHtml(b, node.params[0]); return b.block('link-to', node.params.slice(1), node.hash, buildProgram(b, content, node.loc), null, node.loc); } }, }, }; }
Version data entries
3 entries across 3 versions & 1 rubygems