Created
June 26, 2012 23:55
-
-
Save robert-wallis/3000270 to your computer and use it in GitHub Desktop.
Static Jade Template Builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JADE_C="../node/node_modules/jade/bin/jade" | |
template_OUT=../../static | |
template_JADE=*.jade */*.jade | |
template_HTML=$(foreach source_file, $(template_JADE), ${template_OUT}/${source_file:.jade=.html}) | |
.PHONY: all | |
all: $(template_HTML) | |
$(template_OUT)/%.html: %.jade | |
$(JADE_C) $< --out $(template_OUT)/$(dir $<) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
JADE_C
is the jade compiler, I could use just "jade" but that requires someone has already done "npm install -g jade" and I think on prod that step has not been done, all the source is inside the folder.template_OUT
points to the Nginx root folder for the site, to statically serve up the files, lightning fast.template_JADE
has a cool*/*.jade
expression in it, that will find all the jade files in subfolders, as well as this foldertemplate_HTML
the for loop just does a string replace*.jade
to*.html
.PHONY
all isn't really a file that needs to be made, but just a rule, that depends on all the html being built and up to date.%.html: %.jade
is a rule that says how to build any.html
file from any.jade
file$<
are all the dependencies for this particular html file$(dir $<)
gets the directory/folder name for all the files, because intemplate_JADE
I include not only the current dir, but subdirs too. So this will tell jade to build into that folder. This is the critical step because piping a jade file into thejade
command won't accept filename includes, and thejade
command will not render to a specific file, it only renders to a folder and changes the name to html "for you" automagically.