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
reset css rules when new css is set #87
Conversation
Not reprocessing the rules is broken for inline style tags |
@stof why do you think so? Rules will be reprocessed as soon as new css is set |
Inline css tags are exactly where I came from. Sending bulk email from console was a big pain. Template compilation started from 0.1sec and increased to 8sec after 1000 emails |
Calling |
Ok, now I see. Will provide fix shortly |
Can't you just process your template once and replace the name/email etc? Like with the Decorator plugin in Swiftmailer: http://swiftmailer.org/docs/plugins.html#decorator-plugin |
@barryvdh I'm using symfony bundle that provides twig integration with CssToInlineStyles. There are multiple ways of solving my issue but as for me - there should be no problem with using same instance for multiple templates. Or at least say somewhere that reusing object is not safe. But if it's easy to support object reusage then why not? |
I think caching of css rules is better done through injection of a separate object containing the cache. Even better, the I would even opt to not set the html and the css as properties of the CssToInlineStyles object, but to inject them in the convert method. I think this would greatly improve the flexibility of the class. |
Hello,
This PR fixes issue when reusing same instance of CssToInlineStyles class for inlining, e.g. in bulk emails option. Also it speeds up inlining css a bit for bulk emails by parsing css only once.
Regards,
Alex