svg-inliner

0.0.3 • Public • Published

SVG-inliner

Creates inline HTML from an external SVG (sprite) in an tag.

It extracts the correct SVG element from an SVG sprite if the child's id is put after a # in the src attribute of the image.

Install

If you want to use SVG inliner in node.js and include with CommonJs:

npm install svg-inliner

Or download the svg-inliner.js JavaScript file in the root and place in your project.

Single file usage

Consider the following HTML:

<img id="svg-image" src="path/to/svg.svg" />

Apply SVG-inliner with the following JavaScript:

new SVGInliner(document.querySelectorAll("#svg-image"));

SVG Sprite usage

Image tag in HTML with id of targeted element:

<img id="svg-sprite" src="path/to/svg-sprite-file.svg#id-of-element" />

Use the following JavaScript to get the targeted child of the sprite:

new SVGInliner(document.querySelectorAll("#svg-sprite"));

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    1
  • 0.0.2
    1
  • 0.0.1
    1

Package Sidebar

Install

npm i svg-inliner

Weekly Downloads

3

Version

0.0.3

License

MIT

Last publish

Collaborators

  • gaya