pug - Can I access a variable defined inside a jade template? -
i'm using jade create email templates, have jade file each type of email , each language. i'd able set email subject inside jade template, either reading variable defined inside template or finding contents of title tag can't 1 of those. there way tie html tag function can content? or able access variable defined in jade template?
thanks!
this i've done.
first, i've extended jade.compiler create own compiler rewriting visittag method able catch when title tag used.
subjects = {} emailcompiler = (node, options) -> jade.compiler.call(this, node, options) emailcompiler::__proto__ = jade.compiler.prototype; emailcompiler::visittag = (tag) -> if tag.name 'title' subjects[@options.filename] = @gettext tag.block.nodes[0] jade.compiler.prototype.visittag.call(this, tag) emailcompiler::gettext = (nodes, glue='') -> [].map.call(nodes.nodes, (node) -> node.val).join glue
and jade compiler called this:
fs.readfile filepath, (err, str) -> jade.compile str, compiler: emailcompiler filename: filepath
hope helps somebody!
Comments
Post a Comment