@raw
Disable template processing for a section of content
The @raw directive prevents the Elements template engine from processing content within its block. This is essential when you need to output literal {{ and }} syntax, such as when integrating with external templating systems like Elements CMS or JavaScript templating libraries.
Syntax
@raw()
<!-- Content here will not be processed by Elements -->
@endrawUse Cases
Elements CMS Integration
When using Elements CMS, you need to output CMS template syntax that uses the same {{}} delimiters as the Elements templating language. Wrap CMS-specific code in @raw to prevent Elements from processing it:
@raw()
<div class="text-sm text-black-600">{{item.title}}</div>
@endrawWithout @raw, Elements would try to find a property called item.title and replace it. With @raw, the literal text {{item.title}} is output for the CMS to process at runtime.
CMS Loop Syntax
Preserve CMS loop syntax in your templates:
@raw()
{% for image in item.gallery %}
<img src="{{image.src}}" alt="{{image.alt}}" />
{% endfor %}
@endrawMixing Elements and CMS Syntax
You can exit and re-enter @raw blocks to mix Elements properties with CMS syntax:
In this example:
Elements processes
{{cmsField}}to insert the field nameThe CMS processes the rest at runtime
JavaScript Template Literals
When using JavaScript templating libraries that use similar syntax:
Vue.js or Similar Frameworks
Preserve Vue.js mustache syntax:
Combining with Elements Properties
You can use Elements properties outside @raw blocks to inject dynamic values into CMS templates:
This outputs:
{{classes.wrapper}}- Replaced by Elements with the actual class names{{classes.item}}- Also replaced by Elements{{item.title}}- Preserved literally for CMS processing
Best Practices
Use for external templating only - Only use
@rawwhen integrating with external systems that use{{}}syntax.Keep raw blocks focused - Include only the content that needs to be preserved; exit
@rawwhen you need Elements processing.Document CMS dependencies - When your component uses
@rawfor CMS integration, document this clearly for users.Test both modes - Test your component with and without CMS data to ensure proper fallback behavior.
Related
Elements CMS Documentation - External CMS integration
Last updated
Was this helpful?

