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 $<) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
JADE_Cis 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_OUTpoints to the Nginx root folder for the site, to statically serve up the files, lightning fast.template_JADEhas a cool*/*.jadeexpression in it, that will find all the jade files in subfolders, as well as this foldertemplate_HTMLthe for loop just does a string replace*.jadeto*.html.PHONYall 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: %.jadeis a rule that says how to build any.htmlfile from any.jadefile$<are all the dependencies for this particular html file$(dir $<)gets the directory/folder name for all the files, because intemplate_JADEI 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 thejadecommand won't accept filename includes, and thejadecommand will not render to a specific file, it only renders to a folder and changes the name to html "for you" automagically.