I will not be using node.js in production, but I like jades syntax, so I would like to compile jade template into html
when developing.
Given this file structure:
app/
jade_templates /
index.jade
subfolder /
subpage.jade
html_templates /
index.html
subfolder /
subpage.html
I would like to have a script that watches the jade_templates
directory and compiles the corresponding html template to html_templates
any time a change has been made.
How can this be accomplished?
Thank you.
EDIT The Jade README has this Sample Makefile, but I'm not sure how to adapt this to my needs.
JADE = $(shell find pages/*.jade)
HTML = $(JADE:.jade=.html)
all: $(HTML)
%.html: %.jade
jade < $< --path $< > $@
clean:
rm -f $(HTML)
.PHONY: clean
Jade is a template engine for node. js and the default rendering engine for the Express web framework. It is a new, simplified language that compiles into HTML and is extremely useful for web developers. Jade is designed primarily for server-side templating in node.
According to some benchmark tests, EJS is way faster than Jade or Haml.
Jade is a template engine for Node. js. Jade syntax is easy to learn. It uses whitespace and indentation as a part of the syntax.
Notice that coding using the PUG framework is much easier and more readable than thr HTML codes. PUG makes use of indentation to distinguish between where a tag starts and ends. This makes the code much cleaner than HTML, where lack of indentation and a need for closing tags makes the code a little cluttered.
Since I had the need for a similar script I took the time and tried out a few tools and shell scripts out there (like forever) but couldn't find anything satisfactory.
So I went on to implement this solution. You can find it on github:
https://github.com/mihaifm/simplemon
See if it works for you. I added an example for jade as well.
Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With