Jade-lang add manifest file

I would like to know how to add a manifest file to node.js using jade-lang and express. I found this as question 239 on github. My question is how to add some data to the buffer until we wait for the problem to be resolved.

Thank you in!

0
source share
2 answers

I will need this in one of my projects, so I was curious to try. There is a problem if you try to do this in a single file:

!!! 5 if useManifest html(lang="en", manifest="cache.manifest") else html(lang="en") head title sample title body p some content... 

This displays corrupted HTML. However, everything seems to be working fine (this is definitely a workaround):

In routes\index.js :

 exports.index = function(req, res){ res.render('testJade', { layout: false, useManifest: true }) }; 

In views\testJadeInclude.jade :

 !!!5 if useManifest html(lang="en", manifest="cache.manifest") block content else html(lang="en") block content 

And finally, in views\testJade.jade :

 include testJadeInclude block append content head title sample title body p some content 

Then, based on what you want (for example, if the client is a mobile browser or something else), you set useManifest to true or false.

And I just experienced another opportunity that looks the other way around. Instead of including the doctype and html tags in your content file (by adding a block), you include the content file in the doctype-html file, so it looks like this:

 !!! 5 if useManifest html(lang="en", manifest="cache.manifest") include contentFile else html(lang="en") include contentFile 
0
source

There's an easy way to do it in jade: Just try this.

 html(manifest=_condition_ ? "cache.manifest" : undefined) 

This code checks if the condition is true. If so, the manifest is set to "cache.manifest". Otherwise, it will be set to undefined and omitted.

+2
source

All Articles