You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is broken, or if I'm just doing it wrong. But there is no documentation on how to precompile templates and then load the precompiled template and call it.
I'm generating html on the server, but want to precompile the templates (for performance reasons) and save them as .js. Then at runtime, load the js file and call it with an options hash to generate html.
I see in Handlebars::Context there is a precompile function but it seems to produce different output from npm's handlebars precompile. And once I have it, I can't seem to load it back in, and call it.
I've tried Handlebars::Context.new.handlebars.template(str).apply({}), and variations of that. But still can't get something working.
Can someone update the docs on this, if the functionality is there and working? Or otherwise fix this.
Thanks in advance
The text was updated successfully, but these errors were encountered:
What I found that Handlebars.precompile returns 'js code' which is used by '../dist/cjs/precompiler' and this script generates a javascript that can be used by handlebars.runtime.js
So, to generate a precompiled template that can be used in runtime you will have to write an script similar to cjs/precompiler
I'm not sure if this is broken, or if I'm just doing it wrong. But there is no documentation on how to precompile templates and then load the precompiled template and call it.
I'm generating html on the server, but want to precompile the templates (for performance reasons) and save them as .js. Then at runtime, load the js file and call it with an options hash to generate html.
I see in Handlebars::Context there is a precompile function but it seems to produce different output from npm's handlebars precompile. And once I have it, I can't seem to load it back in, and call it.
I've tried Handlebars::Context.new.handlebars.template(str).apply({}), and variations of that. But still can't get something working.
Can someone update the docs on this, if the functionality is there and working? Or otherwise fix this.
Thanks in advance
The text was updated successfully, but these errors were encountered: