File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,22 @@ require("html?interpolate!./file.html");
122
122
``` html
123
123
<img src =" ${require(`./images/gallery.png`)}" >
124
124
125
+ <div >${require('./components/gallery.html')}</div >
126
+ ```
127
+ And if you only want to use ` require ` in template and any other ` ${} ` are not to be translate you can set ` interpolate ` flag to ` require ` , like so:
128
+
129
+ ``` js
130
+ require (" html?interpolate=require!./file.ftl" );
131
+ ```
132
+
133
+ ``` html
134
+
135
+ <#list list as list>
136
+ <a href =" ${list.href!}" />${list.name}</a >
137
+ </#list>
138
+
139
+ <img src =" ${require(`./images/gallery.png`)}" >
140
+
125
141
<div >${require('./components/gallery.html')}</div >
126
142
```
127
143
Original file line number Diff line number Diff line change @@ -119,4 +119,11 @@ describe("loader", function() {
119
119
'module.exports = "<img src=\\"" + ("Hello " + (1 + 1)) + "\\">";'
120
120
) ;
121
121
} ) ;
122
+ it ( "should enable interpolations when using interpolate=require flag and only require function to be translate" , function ( ) {
123
+ loader . call ( {
124
+ query : "?interpolate=require"
125
+ } , '<a href="${list.href}"><img src="${require(\'./test.jpg\')}" />' ) . should . be . eql (
126
+ 'module.exports = "<a href="${list.href}"><img src=\\"" + require(\'./test.jpg\') + "\\">";'
127
+ ) ;
128
+ } ) ;
122
129
} ) ;
You can’t perform that action at this time.
0 commit comments