{% component %}
Twig Tag
The {% component %}
tag will parse the default markup content for a CMS component and display it on the page. Not all components provide default markup, the documentation for the plugin will guide in the correct usage.
{% component "blogPosts" %}
This will render the component partial with a fixed name of default.htm and is essentially an alias for the following:
{% partial "blogPosts::default" %}
# Variables
Some components support passing variables to them at render time.
{% component "blogPosts" postsPerPage="5" %}
# Customizing Components
In most cases the {% component %}
tag is not needed and the markup is provided as a usage example for the component API. Components are intended to be customized, this can be done in two ways:
- Moving the default markup to a partial
- Overriding component partials using the theme
The CMS Components article outlines the process of customizing default markup.