I want to minify my template when handlebars compiles it in a NodeJS environment.
I searched for this and discovered the handlebars.compile(templateLoaded); has more parameters to pass to it than just the template to compiler. I would like to know how to pass a minify option for function and others options that I can pass.
Here is a link to the handlebars code that allows this: https://github.com/wycats/handlebars.js/blob/271106d43fae96fc1287898568d000b871f19084/lib/handlebars/compiler/javascript-compiler.js
Pay attention to line 46 and 48.
I suggest the following resource: http://www.adamwadeharris.com/how-to-precompile-handlebars-templates/
You can pass it (if you have the cli tool via npm -g install handlebars) the -m flag to minimize, so it would be something like: handlebars -m js/templates/ js/templates/templates.js
and then instead of:
var source = $("#handlebarsScriptId").html();
var template = Handlebars.compile(source);
you pass:
var template = Handlebars.templates.handlebarsScriptId;
and you'll need to include in your html:
<script src="js/handlebars.js"></script>
<script src="js/templates/templates.js"></script>