gruntjs / grunt-contrib-pug

Compile Pug templates.
http://gruntjs.com/
MIT License
328 stars 77 forks source link

Compiling with "client: true" option creates invalid output #169

Open sanojian opened 8 years ago

sanojian commented 8 years ago

By default, compileDebug option is true and invalid output is generated. A "pug_rethrow" function is inserted into the code and it will not parse.

Setting "compileDebug: false" is a workaround to get around this problem until it is fixed.

sanojian commented 8 years ago

It seems that the issue is that somehow the "inlineRuntimeFunctions" option of pug-code-gen is getting set to true by default. If I set this option to false it no longer generates extra code that breaks the parsing.

sumeetattree commented 8 years ago

To add to this, options.inlineRuntimeFunctions is also breaking the output when options.namespace is set to a truthy value. This is the output it generates:

this['Namespace']['fileName'] = function pug_escape(e){...};
function template(locals){...}

To get around this you need to manually set options.inlineRuntimeFunctions to false and include pug-runtime with your template functions.