Email-builder / grunt-email-builder

Build Emails from HTML / CSS code in grunt
Other
94 stars 14 forks source link

Data-ignore on links to web fonts does not work. #36

Closed betsydupuis closed 9 years ago

betsydupuis commented 9 years ago

When trying to use web fonts with stylesheet links, email builder will attempt to read the file even with data-ignore.

 <link rel='stylesheet' data-ignore="ignore" href='http://fonts.googleapis.com/css?family=Lato:300,400,700,900'  type='text/css'>

Here is there error: Warning: Unable to read "http://fonts.googleapis.com/css?family=Lato:300,400,700,900" file (Error code: ENOENT). Use --force to continue.

betsydupuis commented 9 years ago

I was able to fix it: Changed

$styleLinks = $('link');

to....

$styleLinks = $('link:not([data-ignore-link])');

Use data-ignore-link.

Is this pull request worthy?

Also as a side note, this may be useful for including libraries in email clients that support style links.

yargalot commented 9 years ago

Sounds like a plan, @jeremypeter any objections?

jeremypeter commented 9 years ago

I think we can just ignore external styles that are hosted by default instead of creating another attribute. What do you think?

jeremypeter commented 9 years ago

@itsjustluck @yargalot - Actually, now that I think of it, you can just use the juice option removeLinkTags and set it to false within the options object. That will prevent the default action which is to remove all link tags. Make sure you have the latest version of grunt-email-builder as well. I thought I had fixed the issue ENOENT issue.

Example

options: {
    removeLinkTags: false
}
betsydupuis commented 9 years ago

For me, it would still be useful to remove the link tags that need to be removed.

I think that the idea that if it's hosted, it doesn't get inlined is useful, but it might be confusing if it's not explicit.

jeremypeter commented 9 years ago

Version 3.0.0 will fix this. Use the data-embed-ignore attribute on the tags you want to preserve.