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).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top