Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Jade template as a preprocessor for html

Jade template as a preprocessor for html

Problem

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  [email protected]

clean:
    rm -f $(HTML)

.PHONY: clean
Problem courtesy of: Kyle Finley

Solution

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!

Solution courtesy of: mihai

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Jade template as a preprocessor for html

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×