pybars.Compiler().precompile() that is equivalent to Handlebars.precompile()
For performance reasons, I want to render server-side HTML as fast as possible. compile() is too slow, so I was thinking to use precompile(), then store the returned Python code in memcache or database, and if a user request needs a server-sided rendered HTML, the server would pick up the propper precompiled value and run it.
But I'm not sure what to do with the Python code returned by precompile().
var templateSpec = Handlebars.precompile('{{foo}}');
var template = Handlebars.template(templateSpec);
template({});
I couldn't find an equivalent template() in pybars. As far as I understand pybars3 implementation, precompile() and compile() both share common code in _generate_code(). precompile() only uses the container's full_code, and compile() continues with both, the full_code and the name, to render the (HTML) output.
So, what I'm expected to do with the Python code returned by precompile() to get the rendered (HTML) output?
According to the pybars3 README:
For performance reasons, I want to render server-side HTML as fast as possible.
compile()
is too slow, so I was thinking to useprecompile()
, then store the returned Python code in memcache or database, and if a user request needs a server-sided rendered HTML, the server would pick up the propper precompiled value and run it.But I'm not sure what to do with the Python code returned by
precompile()
.(Handlebars.js API reference) [https://handlebarsjs.com/reference.html] explains this usage:
I couldn't find an equivalent
template()
in pybars. As far as I understand pybars3 implementation,precompile()
andcompile()
both share common code in_generate_code()
.precompile()
only uses the container'sfull_code
, andcompile()
continues with both, thefull_code
and thename
, to render the (HTML) output.So, what I'm expected to do with the Python code returned by
precompile()
to get the rendered (HTML) output?