UNPKG

1.33 kBMarkdownView Raw
1# {%= name %} {%= badge("fury") %}
2
3> {%= description %}
4
5Useful for protecting tokens, like templates in HTML, from being mutated when the string is transformed in some way, like from a formatter/beautifier.
6
7**Example without `preserve`**
8
9Let's say you want to use [js-beautify] on a string of html with Lo-Dash/Underscore templates, such as: `<ul><li><%= name %></li></ul>`:
10
11js-beautify will render the template unusable (and apply incorrect formatting because of the unfamiliar syntax from the Lo-Dash template):
12
13```html
14<ul>
15 <li>
16 <%=n ame %>
17 </li>
18</ul>
19```
20
21**Example with `preserve`**
22
23Correct.
24
25```html
26<ul>
27 <li><%= name %></li>
28</ul>
29```
30
31For the record, this is just a random example, I've had very few issues with js-beautify in general. But with or without js-beautify, this kind of token mangling does happen sometimes when you use formatters, beautifiers or similar tools.
32
33## Install
34{%= include("install-npm", {save: true}) %}
35
36## Run tests
37
38```bash
39npm test
40```
41
42## API
43{%= apidocs("index.js") %}
44
45## Contributing
46Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue]({%= bugs.url %})
47
48## Author
49{%= include("author") %}
50
51## License
52{%= copyright() %}
53{%= license() %}
54
55***
56
57{%= include("footer") %}
58
59[js-beautify]: https://github.com/beautify-web/js-beautify
\No newline at end of file