[英]Using the Jade engine on all .jade files regardless of location
I'm using Node and the Express framework for my website, but instead of a separate Views folder, I have a site structure where the .jade files could be anywhere within a static
folder. 我正在为我的网站使用Node和Express框架,但是没有一个单独的Views文件夹,而是一个网站结构,其中.jade文件可以位于
static
文件夹中的任何位置。
What's the simplest way of getting jade to compile the templates if they end in .jade? 如果Jade以.jade结尾,最简单的方法是让Jade编译这些模板? Do I have to write a middleware function for the regex
\\.jade$
? 我是否需要为正则表达式
\\.jade$
编写中间件功能? How would I do this? 我该怎么做?
Use glob. 使用glob。 Pattern will be '**/*.jade' https://www.npmjs.org/package/glob
模式将为'** / *。jade'https: //www.npmjs.org/package/glob
You need to tell node where the templates can be found. 您需要告诉节点可以在哪里找到模板。 Typically, this is done like this
通常,这样做是这样的
app.set('views', '/static/views'); // templates are found in /static/views folder
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.