Skip to content

Commit

Permalink
Alternative template to template literal
Browse files Browse the repository at this point in the history
closes #84
  • Loading branch information
inuscript authored and stevemao committed Apr 24, 2017
1 parent e90b046 commit a08ffc7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ then Lodash/Underscore is the better option.*
1. [_.toLower](#_tolower)
1. [_.toUpper](#_toupper)
1. [_.trim](#_trim)
1. [_.template](#_template)


## Array
Expand Down Expand Up @@ -1051,6 +1052,29 @@ Removes the leading and trailing whitespace characters from a string.
**[⬆ back to top](#quick-links)**
### _.template
:heavy_exclamation_mark: *Note this is an alternative implementation. Native template literals not escape html.*
Create a template function.
```js
// Lodash/Underscore
const compiled = _.template('hello <%= user %>!');
compiled({ 'user': 'fred' });
// Native
const templateLitreal = (value) => `hello ${value.user}`;
templateLiterlFunction({ 'user': 'fred' });
```
### Browser Support
![Chrome][chrome-image] | ![Firefox][firefox-image] | ![IE][ie-image] | ![Opera][opera-image] | ![Safari][safari-image]
:-: | :-: | :-: | :-: | :-: |
41 ✔ | 34 ✔ | Not supported | 28 ✔ | 9 ✔ |
**[⬆ back to top](#quick-links)**
## Reference
Expand Down

0 comments on commit a08ffc7

Please sign in to comment.