Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

EE doesn't seem to be parsing {snippet} tags inside a template of type stylesheet - I'm guessing because the curly braces conflict with CSS's own braces indicating the start of a style declaration. Is there a way to sort of escape these characters or something?

Ex:

.style { /* CSS curly brace */
  width: {snippet_width}px; /* EE curly brace */
}
share|improve this question

2 Answers 2

up vote 4 down vote accepted

While use cases for it are rare, CSS templates can parse tags if you need them to, but you must link to them with {path='template_group/css_template'} instead of {stylesheet='template_group/css_template}.

share|improve this answer

EE's CSS and JS templates do not parse variables or tags. They're just static templates. Best to avoid EE altogether and just create CSS and JS files on the server. To still be somewhat dynamic, you can always hard-code rules in the <head> (for CSS) or above </body> (for JS). For example:

<style>
   .style {
       width: {snippet_width}px;
   }
</style>
share|improve this answer
    
Whether or not CSS templates parse tags depends on how you are linking to them. The point is correct though that in almost all cases, it is best to serve these types of assets as real files on the server. –  Derek Jones May 19 at 16:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.