10

How would I use handlebars to pre-compile a template to html and save the resulting HTML as a static HTML file, is it possible to do this? Based on what I've been reading it isn't but I was hoping maybe there is a Grunt task or something I missed...

3
  • You could visit the page and have javascript send the page's html to the server in an ajax request and then have the server save it to a file. If you want something more automated, you could use phantomjs, a headless browser, to automatically create/update files on a set schedule. That is a standard approach to creating SEO snapshots of ajax sites. If this is the answer you're looking for, I'll post it. :) Commented Jan 2, 2014 at 16:07
  • I'm thinking this is more of a build process/pre-deploy task, like I have some data, I have some templates, I want to compile them together into one static HTML file and then deploy the HTML. Commented Jan 2, 2014 at 16:11
  • Right, and since javascript does the compiling and you want the process to be automated, you would use phantomJS to "visit" those pages for you and export the compiled html. Commented Jan 2, 2014 at 16:14

1 Answer 1

10

This that does what I was looking for https://github.com/patrickkettner/grunt-compile-handlebars

Sign up to request clarification or add additional context in comments.

1 Comment

Very useful because this is exactly what I was looking for :-) I have a dynamic website but I think compiling templates once every 15 minutes into static files would work well. Keeping the actual webserver dumb. Certainly gone give it a try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.