Skip to content

Commit 1b82675

Browse files
lettertwosokra
authored andcommitted
Update README with info about query param
1 parent c786715 commit 1b82675

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,29 @@ require("html?attrs[]=img:src&attrs[]=img:data-src!./file.html");
4444

4545
/// minimized by running `webpack --optimize-minimize`
4646
// => '<img src=http://cdn.example.com/49e...ba9f/a9f...92ca.jpg data-src=data:image/png;base64,...>'
47+
48+
```
49+
50+
## 'Root-relative' urls
51+
52+
For urls that start with a `/`, the default behavior is to not translate them.
53+
If a `root` query parameter is set, however, it will be prepended to the url
54+
and then translated.
55+
56+
With the same configuration above:
57+
``` html
58+
<!-- fileB.html -->
59+
<img src="/image.jpg">
60+
```
61+
62+
``` javascript
63+
64+
require("html!./fileB.html");
65+
// => '<img src="/image.jpg">'
66+
67+
require("html?root=.!./fileB.html");
68+
// => '<img src="http://cdn.example.com/49e...ba9f/a9f...92ca.jpg">'
69+
4770
```
4871

4972
## License

0 commit comments

Comments
 (0)