express.js中的服务器端包含 [英] Server-side includes in expressjs
本文介绍了express.js中的服务器端包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过express.js生成服务器端包含?
Is it possible to generate Server side includes with express.js?
我试图在不同页面上重复使用页眉和页脚标记,以便可以在一个地方进行页眉/页脚更改.
I'm trying to reuse my header and footer markup on different pages so I can make header/footer changes in one place.
推荐答案
尝试使用局部函数.
您必须在某些模板引擎之间进行选择.默认的模板引擎是jade,因此您必须执行以下操作:创建一个文件views/header.jade并将其放入.在操作中,您可以使用partial('header');
Try to use partials.
You have to choose between some template engines. The default template engine is jade, so for this you have to do the following: create a file views/header.jade and put your stuff in. in your action you can render the partial with partial('header');
有关更多信息,请参见 expressjs文档.
See the expressjs docs for more.
这篇关于express.js中的服务器端包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文