handlebars-loader icon indicating copy to clipboard operation
handlebars-loader copied to clipboard

Is it possible to compile templates programmatically with handlebars-loader?

Open neenhouse opened this issue 9 years ago • 2 comments

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?

neenhouse avatar Aug 27 '15 13:08 neenhouse

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 avatar Sep 16 '15 21:09 altano

@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?

eunkyungkim avatar Oct 15 '15 09:10 eunkyungkim