Add user callback support
TrySound opened this issue · 3 comments
Need to get svgjs data
Could you please elaborate? What's the use case?
I use gulp-svgstore and want to add style="display: none"
without cheerio.
SVG2JS
seems like an internal API for SVGO; the AST is not returned with the optimised SVG. It might be worth extracting that conversion into a separate module which SVGO could consume, but in this case I think it might be better to have a gulp plugin that was about SVG AST manipulation (which would consume that hypothetical SVG2JS/JS2SVG
extraction).
In most cases, people will not need the extra transformation that you would like here, and if they do, I think it is worth using a separate module to achieve it; it keeps this module small and focused. Plus, gulp-svgstore's README already has a one-line callback which I think should do the job:
var gulp = require('gulp');
var svgstore = require('gulp-svgstore');
var cheerio = require('gulp-cheerio');
gulp.task('svgstore', function () {
return gulp
.src('test/src/*.svg')
.pipe(svgstore({ inlineSvg: true }))
.pipe(cheerio(function ($) {
$('svg').attr('style', 'display:none');
}))
.pipe(gulp.dest('test/dest'));
});
I'm not sold on adding this, it doesn't seem like you'll get any benefit over using cheerio
(which is an excellent module), and it bloats the API for introducing a feature that will only be used in edge cases.