blob: 43501858c56f15ccc0c62924ad24ceb4aaafd2a1 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
 | @use "str-replace" as fun;
/// Encode a SVG.
/// @param {String} $svg A complete svg (`<svg>...</svg>`).
/// @return The encoded svg, ready to use for background-image.
@function encode-svg($svg) {
  $svg-encoding: (("<", "%3C"), (">", "%3E"), ("#", "%23"));
  @each $char, $encoded in $svg-encoding {
    $svg: fun.str-replace($svg, $char, $encoded);
  }
  @return "data:image/svg+xml;utf8," + $svg;
}
 |