-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't render CSS in defs mode #45
Comments
Hi @lookfortheroot, this is a duplicate of grunt-svg-sprite issue #31. As it happens, I'm just about adding the possibility to render a CSS (et al.) with the shape dimensions. What else would you need? Cheers, |
Same render possibilities like in css/view modes would be nice. |
Well, the very same don't make any sense (and are impossible, by the way). By definition, a |
Well, this is right. |
Thou shalt get that. ;) I might delay the next release until Monday, however, as I'd like to wait for the upcoming lodash release. By the way, that SVG injection approach you are talking about will most likely be featured in one of my next iconizr releases, then including support for PNG fallbacks as well. I might consider backporting the SVG part into svg-sprite as well. |
Should work now, although still undocumented. Just use it as you would do with Cheers, |
Yay, this was fast. Thanks a lot 👍 |
You're welcome. As I said, I was just about it anyway. Didn't spend too much time testing though — would be nice if you could give me some feedback if this works for you. :) |
It almost works ;)
|
No, it's not. I double checked it with different output modes and all the stylesheet resource types. I get a dot, always. Any chance there's another problem on your side? Did you alter the
I'm not sure if I completely understand your problem. In case you set the
By default, almost every SVGO plugin is enabled. These are the defaults: defaultPluginConfig = [
// {cleanupAttrs : true}, // cleanup attributes from newlines, trailing and repeating spaces
// {removeDoctype : true}, // remove doctype declaration
// {removeXMLProcInst : true}, // remove XML processing instructions
// {removeComments : true}, // remove comments
// {removeMetadata : true}, // remove `<metadata>`
// {removeTitle : true}, // remove `<title>`
// {removeEditorsNSData : true}, // remove editors namespaces, elements and attributes
// {removeEmptyAttrs : true}, // remove empty attributes
// {removeHiddenElems : true}, // remove hidden elements
// {removeEmptyText : true}, // remove empty Text elements
// {removeEmptyContainers : true}, // remove empty Container elements
// {removeViewBox : true}, // remove `viewBox` attribute when possible
// {cleanupEnableBackground : true}, // remove or cleanup `enable-background` attribute when possible
// {convertStyleToAttrs : true}, // convert styles into attributes
// {convertColors : true}, // convert colors (from `rgb()` to `#rrggbb`, from `#rrggbb` to `#rgb`)
// {convertPathData : true}, // convert Path data to relative, convert one segment to another, trim useless delimiters and much more
// {convertTransform : true}, // collapse multiple transforms into one, convert matrices to the short aliases and much more
// {removeUnknownsAndDefaults : true}, // remove unknown elements content and attributes, remove attrs with default values
// {removeNonInheritableGroupAttrs : true}, // remove non-inheritable group's "presentation" attributes
// {removeUnusedNS : true}, // remove unused namespaces declaration
// {cleanupIDs : true}, // remove unused and minify used IDs
// {cleanupNumericValues : true}, // round numeric values to the fixed precision, remove default 'px' units
// {moveElemsAttrsToGroup : true}, // move elements attributes to the existing group wrapper
{moveGroupAttrsToElems : false} // move some group attributes to the content elements
// {collapseGroups : true}, // collapse useless groups
// {removeRasterImages : false}, // remove raster images (disabled by default)
// {mergePaths : true}, // merge multiple Paths into one
// {convertShapeToPath : true}, // convert some basic shapes to path
// {transformsWithOnePath : true}, // apply transforms, crop by real width, center vertical alignment and resize SVG with one Path inside
], Only the |
|
I'm sorry, but I think that what you're trying to achieve is something that is specific to your SVG injection approach — which is not what the
|
Of course, this is one of the best methods. That is why I try combine best parts:
So using |
I'm still thinking about removing the width |
As of release v1.0.13 you can control whether you want to have |
It works. Thanks! |
But I have last question. I don't understand, how in Gulp to pass calculated value to template? I always get errors:
|
Please refer to the Mustache documentation to learn about the usage of callbacks (which seems, in general, a legit solution for your problem). AFAIK you may only pass strings to these functions, and you won't be able to pass the |
I meant I can't find right object for calculates.
Etc etc. I don't understand how to do it. |
Please read my previous comment. You cannot pass in objects to Mustache functions, only strings. In the template you need to use something like: {{#padtop}}width|height{{/padtop}} and then in function: padtop: function() {
return function(dimensions, render) {
dimensions = dimensions.split('|');
/* ... */
}
} |
Sorry for my English, it seems I poorly explained and you misunderstood me :)
And in the template something like: |
Please re-read my comment above — most of the answer to your problem stands written there. The variables available in each template are documented here. You will want to go for |
Is it really impossible to render css/stylus/etc in defs mode? Need this for full control with CSS, e.g. adaptive sizing.
I did read all docs and I see this possible only in css/view modes.
The text was updated successfully, but these errors were encountered: