How to use the svg-sprite.renderTask function in svg-sprite

To help you get started, we’ve selected a few svg-sprite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jkphl / node-iconizr / lib / iconizr.js View on Github external
if (this.result.data.svg.length) {
		
		// Run through all configured rendering types
		for (var type in this._options.render) {
			var render							= SVGSprite.renderConfig(this._options.outputDir, this._options.render[type], type, __dirname);

			// If both a template and a destination file are given: Create tasks for it
			if (render.dest !== null) {

				if (this._options.verbose > 0) {
					console.log('Creating the "%s" output type ...', type);
				}
				
				// Non-stylesheet output types: Simple rendering
				if (['html', 'inline.svg'].indexOf(type) >= 0) {
					tasks[type]						= SVGSprite.renderTask(render.template, dest + '.' + type, _.extend({}, data), this.result);
					
				// Stylesheet output type: Render variants
				} else {
					++this.output;
					var data						= setDataAndSingle(_.extend({}, this.result.data), this.result.data, 'svg'),
					dest							= path.join(path.dirname(render.dest), path.basename(render.dest, '.' + type));
					
					// Render the SVG sprite version
					tasks[type + '-svg-sprite']		= SVGSprite.renderTask(render.template, dest + '-svg-sprite.' + type, _.extend({}, data, {encode: !this.result.data.exceed.svg}), this.result);
					
					// Render the SVG data version
					tasks[type + '-svg-data']		= SVGSprite.renderTask(render.template, dest + '-svg-data.' + type, _.extend({}, data, {sprite: null, common: null, encode: !this.result.data.exceed.svg}), this.result);
					
					// Render the single SVG icon version (if applicable)
					if (this._options.keep) {
						tasks[type + '-svg-single']	= SVGSprite.renderTask(render.template, dest + '-svg-single.' + type, _.extend({}, data, {sprite: null, common: null, encode: false}), this.result);

svg-sprite

SVG sprites & stacks galore — A low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites of several types along with suitable stylesheet resources (e.g. CSS, Sass, LESS, Stylus, etc.)

MIT
Latest version published 1 month ago

Package Health Score

80 / 100
Full package analysis