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...
-
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. :)m59– m592014-01-02 16:07:28 +00:00Commented 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.Tony Ranieri– Tony Ranieri2014-01-02 16:11:31 +00:00Commented 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.m59– m592014-01-02 16:14:17 +00:00Commented Jan 2, 2014 at 16:14
Add a comment
|
1 Answer
This that does what I was looking for https://github.com/patrickkettner/grunt-compile-handlebars
1 Comment
Gijs
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.