Jade模板作为html的预处理器

我不会在生产中使用node.js ,但是我喜欢jade的语法,所以我想在开发时将jade模板编译成html

鉴于这个文件结构:

 app/ jade_templates / index.jade subfolder / subpage.jade html_templates / index.html subfolder / subpage.html 

我想有一个脚本jade_templates目录并编译相应的html模板html_templates任何时候进行更改。

这怎么能做到呢?

谢谢。

编辑翡翠自述有这个示例Makefile,但我不知道如何适应这个我的需要。

 JADE = $(shell find pages/*.jade) HTML = $(JADE:.jade=.html) all: $(HTML) %.html: %.jade jade < $< --path $< > $@ clean: rm -f $(HTML) .PHONY: clean 

因为我需要一个类似的脚本,我花了一些时间,尝试了一些工具和shell脚本(像永远 ),但没有find任何满意的东西。

所以我继续实施这个解决scheme。 你可以在github上find它:

https://github.com/mihaifm/simplemon

看看它是否适合你。 我还加了一个玉器的例子。

干杯!

我用这个Grunt 。 使用grunt-contrib-jade和grunt-contrib-watch你可以很容易地设置一个咕噜的任务来观察一个目录中的jade文件,并在它们改变时将它们编译到另一个目录。

Grunt有一点点的学习曲线,但它非常方便,并且允许我在Jade(和Sass,以及Coffeescript!)中进行切实的开发 – 如果您对这种方法感兴趣,请发表评论,我会添加一个示例Gruntfile,可以做你想做的事情。

我build议你写一个小节点的应用程序来做到这一点。

代码看起来像这样:

 // Watch a directory for files changes (such as here: https://github.com/Raynos/fyp/blob/master/src/build.js) // Get the Jade code from the changed file // Compile it // Writes the output to a file with the same name in another directory 

我说“节点应用程序”,但它应该是任何你感到舒服的。