How can I provide parameters for webpack html-loader interpolation?

前端 未结 7 1029
暖寄归人
暖寄归人 2020-12-05 02:36

In the html-loader documentation there is this example

require(\"html?interpolate=require!./file.ftl\");

<#list list as list>
    

        
7条回答
  •  清歌不尽
    2020-12-05 03:14

    mustache-loader did the work for me:

    var html = require('mustache-loader!html-loader?interpolate!./index.html')({foo:'bar'});
    

    Then in your template you can use {{foo}}, and even insert other templates

    {{foo}}

    ${require('mustache-loader!html-loader?interpolate!./partial.html')({foo2: 'bar2'})}

提交回复
热议问题