Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to include html file or snippet directly in jade?

Tags:

node.js

pug

I have a set of html files, mostly static, I would like to move to my node.js/express/jade project. What's the right way to include html file or snippet directly in jade? I don't want to translate existing html file to jade?

like image 277
jason chen Avatar asked Jul 27 '13 22:07

jason chen


2 Answers

You should be able to simply include it within a jade template:

As mentioned include can be used to include other content such as html or css. By providing an extension, Jade will read that file in, apply any filter matching the file's extension, and insert that content into the output.

html   // ...   body     // ...     //- html files have no filter and are included verbatim     include content.html 
like image 118
Jonathan Lonowski Avatar answered Oct 11 '22 11:10

Jonathan Lonowski


Use :verbatim before the exact html code or snippet directly in jade.

doctype html html(lang="en")   :verbatim     {% include head.html %}   body     :verbatim     {{ content }}    :verbatim     {% include footer.html %} 

Output

<!DOCTYPE html> <html lang="en">{% include head.html %}   <body>{{ content }}   </body>{% include footer.html %} </html> 
like image 42
X.Creates Avatar answered Oct 11 '22 12:10

X.Creates