jonkemp / inline-css

Inline css into an html file.
MIT License
429 stars 84 forks source link

Handling of '=' (equals) symbol outside of HTML attributes #39

Closed ClementParis016 closed 8 years ago

ClementParis016 commented 8 years ago

Hey there,

So, the following code:

var inlineCss = require('inline-css');
var html = "<style>h2{color:red;}</style><h2><%= raw_slide_data slide, :title %></h2>";

inlineCss(html, {applyStyleTags: false, url: 'https://google.com'})
    .then(function(html) { console.log(html); });

Returns:

<h2><%= raw_slide_data="" slide,="" :title="" %=""></%=></h2>

I guess the equals symbol in the opening ERB delimiter (<%=) is what makes inliner add others equals and double quotes. Should we consider this as an issue? Or maybe there is a way I could work around this?

For the story, I'm working on building emails with Foundation for Emails (this tells you from how far I'm coming down the road to solving my problem) to use within a Rails project (that's why I have ERB variables in my HTML).

jonkemp commented 8 years ago

It only supports HTML as far as I'm aware. So templating code is not supported at this time.

ClementParis016 commented 8 years ago

Ok, thanks, I will take a closer look at the source to see if I can tweak this to suit my own use case.

marvinhuebner commented 7 years ago

@ClementParis016 did you found a solution for this? I have also some trouble with templating code and the inliner (through foundation for emails)

https://github.com/zurb/foundation-emails/issues/656

ClementParis016 commented 7 years ago

@marvinhuebner indeed I did found a solution. The inliner was escaping special characters so I had to encode it first, then run the inliner and then decode the output. I can't remember exactly how I did it, but I can get back to the project later and come back to you if you want to know the details ;)