Skip to content

Commit

Permalink
Merge branch 'popinguy-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jkphl committed Jan 18, 2020
2 parents 12b26e2 + 4124fde commit 763370c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Update documentation to use updated SVGO plugin name ([#275](https://github.com/jkphl/svg-sprite/pull/275))
* Move `mocha` and `should` dependencies back to `devDependencies` again ([#297](https://github.com/jkphl/svg-sprite/pull/297), [#285](https://github.com/jkphl/svg-sprite/issues/285))
* Add built-in templating function to encode hash signs ([#294](https://github.com/jkphl/svg-sprite/pull/294))

## 1.5.0 Maintenance release (2018-09-18)

Expand Down
10 changes: 10 additions & 0 deletions docs/templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ Finds all backslashes in a string and escapes each of them with another backslas
}
```

#### encodeHashSign

Finds all hash signs in a string and encodes each of them to `%23`.

```css
.{{name}}-background {
background: url('data:image/svg+xml;utf-8,{{#encodeHashSign}}{{{svg}}}{{/encodeHashSign}}') no-repeat;
}
```


[npm-url]: https://npmjs.org/package/svg-sprite
[npm-image]: https://badge.fury.io/js/svg-sprite.png
Expand Down
5 changes: 5 additions & 0 deletions lib/svg-sprite/layouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ defaultVariables = {
return function(str, render) {
return render(str).split('\\').join('\\\\');
};
},
encodeHashSign : function() {
return function(str, render) {
return render(str).split('#').join('%23');
};
}
};

Expand Down

0 comments on commit 763370c

Please sign in to comment.