Follow these steps to get a Handlebars node compiler setup on your local machine
Note: On Mac OSX, all of the following commands will be done via Terminal. For Windows users that use the Node installer, use the program “Node.js command prompt” that is added when you install node.
- install node
- brew install node
- If you don’t have homebrew – install it with ruby:
- /usr/bin/ruby -e “$(curl -fsSkL raw.github.com/mxcl/homebrew/go)”
- Alternatively, you can also download the Node installer
- curl https://npmjs.org/install.sh | sh
- If you used the Node installer, you may most likely skip this step as npm will already be pre-installed (check with cmd “npm”)
- npm install handlebars -g
- verify with ‘which handlebars’
- create a folder named “templates” and place your “*.handlebars” templates into this folder
- now compile those templates
- handlebars /path-to-template-folder/templates -f /path-to-template-js-file/template.js -m true
Congratulate yourself – you have now compiled your first handlebar template!