Clive Portman: code

Prevent Twig parsing code within Craft CMS

Including minimised CSS within my _layout.html <head> I was having problems with Twig comments wherever an element's id was inside a media query, e.g.

@media (min-width: 1024px{#myelemendid{display:block;}}

would result in the template error:

Unclosed comment.

The solution is to prevent Twig parsing the CSS using {% verbatim %} like so:

{% verbatim %}
    @media (min-width: 1024px{#myelemendid{display:block;}}
{% endverbatim %}