nunjucks-loader icon indicating copy to clipboard operation
nunjucks-loader copied to clipboard

Inline svg loader returns [object Object]

Open DiogoBatista opened this issue 5 years ago • 1 comments

Hello @at0g,

I've been trying to use your loader for a project I'm working on. We are using nunjucks as the render engine combining it with Storybook to visualize the components in a nice way.

And we are having some issues with the SVG, I saw in previous issues that you suggested using the following to render SVG's but I always get [object Object] instead of the actual SVG inline.

  {{ 'svg-loader!./svg_to_render.svg' | require }}

Version used: "nunjucks-loader": "^3.0.0"

  • Do you have any idea why this is happening?

Thank you so much for the nice loader and keep up with the good work 👏

DiogoBatista avatar Jan 02 '20 14:01 DiogoBatista

Because svg-loader returns JSON object, i guess?

If you want to render inline SVG, use raw-loader, see example in readme https://github.com/at0g/nunjucks-loader#filters-and-extensions

ogonkov avatar Jan 09 '20 13:01 ogonkov