PUG templates tips
Recipes
Compile pug file locally in command line
pug -O '{"pretty": true}' sr-order.template.pugMixins with block (to wrap content inside a mixin)
How to use a json for data in commande line
Option 1
This insane mixin works:
mixin json()
- var oldbuf = buf; buf = [];
block
- var res = JSON.stringify(JSON.parse(buf.join('')));
- buf = oldbuf;
!= res
You can then call it:
+json().
[
{
"name": "ABC-Logistic",
"file": "Abc-logistic",
"link": "abc-logistic.co.jp"
}
]
And the resulting file will contain:
[{"name":"ABC-Logistic","file":"Abc-logistic","link":"abc-logistic.co.jp"}]How to load data in a grunt base environnement
Multiline js in jade (work in progress)
unescaped html tags inside a variable
Conditional attributes
Multiline tag content
Dynamic Mixin call
Dynamic attributes
Debug pug or jade
unexpected token "indent" :
"Unexpected token 'tag' expected 'text', 'code', ':', 'newline' or 'eos'"
Last updated