Search code examples
node.jshandlebars.jsprecompile

Handlebars precompiling can't seem to build the file


Currently I have a template folder with lots of handlebar templates with .htm extension. I pull them in on the fly as needed, so don't have the script tags around. I am looking to compile these templates, so I don't have to do it client side.

I have downloaded NodeJS and installed Handlebars, but having a problem with compiling. Here are some things I have tried:

handlebars "C:\Users\My Name\Desktop\path\to\templates\>" -m "C:\Users\My Name\Desktop\path\to\scripts\templates.min.js" -e "htm"

This gives a Unexpected String error.

node ./bin/handlebars "C:\Users\My Name\Desktop\path\to\templates\>" -m "C:\Users\My Name\Desktop\path\to\scripts\templates.min.js" -e "htm"

This shows a "..." and won't let me do anything else.

I want the file to be minimized (-m) and all files have a .htm file extension, which is why I am using -e.

I have custom helpers, but don't want those to trigger until I'm sending data into them anyways. Do I have to list every single helper that is registered with a -k?


Solution

  • I was using the wrong console. Needed to use the NodeJS command line. Also, needed to adjust my call like:

    handlebars -m "C:/Users/My Name/Desktop/path/to/templates/" -f "C:/Users/My Name/Desktop/path/to/templates.min.js" -e "htm"