handlebars-loader
handlebars-loader copied to clipboard
Is it possible to compile templates programmatically with handlebars-loader?
I need to compile a dynamic template and I want to reuse the relative locations of my helpers. Is there an easy way to do this with handlebars-loaders?
You can continue to use Handlebars at runtime, including compiling new templates programmatically, but you won't be using webpack or handlebars-loader at that point. Those don't run at runtime in the browser, just their output does.
If you can describe what you're trying to do a little more concretely, perhaps I can help you think up a solution?
@altano I have similar problems.
// main.hbs
<div class="wrapper row-offcanvas row-offcanvas-left">
<!-- Left side column. contains the logo and sidebar -->
<aside class="left-side sidebar-offcanvas">
{{> left-sidebar}}
<!-- /.sidebar -->
</aside>
<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side">
{{> (contentPartial "a") }}
</aside>
<!-- right-side -->
</div>
// contentPartial.js
module.exports = function(context) {
if (context === "a"){
return "right-sidebar";
}else {
return "right-sidebar1";
}
};
error
Uncaught Error: The partial right-sidebar could not be found
File right-sidebar.hbs exists.
How do I precompile all partials using Handlebars-loader? And I hope just contentPartial area be replaced with specific partial after ajax call. What are some ways I can?