Reputation: 28208
Compiling a such template with dustc
:
$ cat <<EOF | ./node_modules/.bin/dustc -
<p>Hi there!</p>
<p>I'm a {! dust !} template.</p>
EOF
outputs:
(function(){dust.register("-",body_0);function body_0(chk,ctx){return chk.write("<p>Hi there!</p><p>I'm a template.</p>");}return body_0;})();
but without \n
between lines, eg: "<p>Hi there!</p>\n<p>I'm a template.</p>"
Is there any way to change this? Thank you
Upvotes: 1
Views: 1272
Reputation: 592
You can disable whitespace compression with
dust.optimizers.format = function(ctx, node) { return node };
Precompiling with gulp-dust, there's a preserveWhitespace
option that does just that:
var compile=require('gulp-dust');
// ...
gulp.src('templates/**/*.dust')
.pipe(compile({ preserveWhitespace: true }))
// ...
Upvotes: 1
Reputation: 5609
You can use {~n}
to create line breaks in your Dust templates. It's is especially useful within <pre>
tags.
Upvotes: 3