Skip to content

Instantly share code, notes, and snippets.

@STRd6
Last active August 29, 2015 13:58
Show Gist options
  • Save STRd6/10400709 to your computer and use it in GitHub Desktop.
Save STRd6/10400709 to your computer and use it in GitHub Desktop.
Mush templates into JST
#! /bin/bash
cd templates
for file in *.haml; do
hamlet < $file -r "Hamlet" > ${file/.haml}.js
done
for file in *.js; do
echo "(window.JST || (window.JST = {}))['${file/.js}'] = " > tmpfile
cat $file >> tmpfile
mv tmpfile $file
done
cat *.js > ../templates.js
@STRd6
Copy link
Author

STRd6 commented Jun 10, 2014

When run from the root directory of your project, and assuming your templates are in ./templates and have the .haml suffix, mu.sh will compile all .haml files into .js files, export them on the global window.JST and concat them into a single ./templates.js file in the root directory of your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment