1

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 */
}

2 Answers 2

4

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}.

2

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>
1
  • 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. Commented May 19, 2014 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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