Keystone-classic: Unable to configure Jade options

Created on 13 Apr 2016  路  9Comments  路  Source: keystonejs/keystone-classic

I need to disable the Jade pretty option in both development and production so HTML is minified, to avoid whitespace issues when display: inline-block components are looped next to each other.

Looking at the way Keystone renders the views here, this should at least happen if you set the node env to production. I tried this to no effect.

Regardless, I would like to be able to configure Jade for development.

Is there a workaround in the meantime?

Most helpful comment

I've made it so you can now specify pretty in the locals setting, and it won't be overridden which fixes this issue! Also published a new patch with the change in it (0.3.21) since I didn't get a chance to add this in the last release.

All 9 comments

We're closing all questions and support requests to keep the issue tracker unpolluted. Please ask this question on Stackoverflow or Gitter instead!

This really is an issue. There is no way to configure Jade in Keystone and quality suffers. Having uncompressed HTML in development and compressed production prevents certain layout techniques and causes surprising layout bugs moving between development and production.

.tile {
  display: inline-block;
  width: 50%;
}
<div>
  <div class="tile">Foo</div>
  <div class="tile">Foo</div>
</div>

Renders the tiles in 2 rows.

<div><div class="tile">Foo</div><div class="tile">Foo</div></div>

Displays tiles in 2 columns.

Ideally, Jade alway runs without --pretty and you opt in to it if desired.

Wow, that is genuinely surprising. I was under the impression that whitespace (not spaces between elements but newline+tabs) were ignored by browsers.

We're prepping an 0.3 patch release, I'll see what can be done to open those options up for you.

+1

In the meantime, for others stuck, and not a permanent fix/solution:

response.locals.pretty = false

Inside route middleware seems to force Jade to ignore earlier config and render minified HTML.

@arthurcamara1 that's actually only having an impact on the Admin UI which isn't relevant to this issue; the problem here is being able to configure pretty in the default express locals

I've made it so you can now specify pretty in the locals setting, and it won't be overridden which fixes this issue! Also published a new patch with the change in it (0.3.21) since I didn't get a chance to add this in the last release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

christroutner picture christroutner  路  4Comments

sarmadsangi picture sarmadsangi  路  5Comments

joernroeder picture joernroeder  路  5Comments

Twansparant picture Twansparant  路  5Comments

josephg picture josephg  路  4Comments