krakenjs / kraken-js

An express-based Node.js web application bootstrapping module.
Other
4.94k stars 459 forks source link

How to keep whitespace after template rendering? #181

Closed mickeyckm closed 10 years ago

mickeyckm commented 10 years ago

Hi,

How can I keep the whitespaces in the template after the rendering by dustjs? Is there a settings for me to do that easily?

Cheers, Mickey

kurdin commented 10 years ago

app.requestBeforeRoute = function requestBeforeRoute(server) { require('dustjs-linkedin').optimizers.format = function(ctx, node) { return node }; };

cmaldonadowilson commented 10 years ago

Good solution.

jeffharrell commented 10 years ago

@kurdin nailed it. This is how it's documented on the dust site, although I agree that it's a bit obscure. I'm closing this out, but am curious, what is the benefit of keeping the whitespace intact? Are you using <pre /> elements to format text?

englishbulldog commented 10 years ago

Would it be possible to set whitespace options of a particular route? I tried putting @kurdin 's code in server.use('/api'...) but it seems that all pages now retain their whitespaces.