Skip to main content
trench999
Level 4
Oct 16, 2015 2:27 AM UTC
Solved

Embed CSS in Email JSP template

It is best practice to place styles inline and in the <head> for an HTML email to cover the most clients.  As we add components to an email, how can we inject styles into the <head> of the email being developed.  If we simply include the clientLibs we get a linked resources so that doesn't work.  Someone mentioned inputStream.  Is that the best way and if so, can someone point us to an example of this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Feike_Visser1
Feike_Visser1Accepted solution
Adobe Employee
Oct 16, 2015 2:27 AM UTC

Look at the code here:

https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/VersionedClientlibsTransformerFactory.java

This code shows you how to read the content of a clientlib, check this line: htmlLibrary.getInputStream()

This you can use to write some custom code around it.

3 replies

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
Oct 16, 2015 2:27 AM UTC

Look at the code here:

https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/VersionedClientlibsTransformerFactory.java

This code shows you how to read the content of a clientlib, check this line: htmlLibrary.getInputStream()

This you can use to write some custom code around it.

Translate
trench999
trench999Author
Level 4
Oct 16, 2015 2:27 AM UTC

We are using clientLibs extensively of course, but emails need "inline" styles in the element tags and in the head and not linked libs.

Translate
smacdonald2008
Level 10
Oct 16, 2015 2:27 AM UTC

Most AEM developers use ClientLibs to handle CSS - as discussed in this official AEM documentation:

http://docs.adobe.com/docs/en/cq/current/developing/clientlibs.html

Why are you opposed to using Clientlibs in an AEM solution? 

Translate