Can I use includes or macros using Jade?
题
I'm using Jade as templating engine for an app on node.js/express.
I don't want to repeat code in different views. Is there any way to define macros/includes/functions like in freemarker?
解决方案
Use partial views.
Check out the screencasts specifically the partial view one.
Be wary partials are defined by express and not the view engine. You'll have to emulate them if you want to use your views outside of express (the API for partials is pretty good).
不隶属于 StackOverflow