Skip to main content

r:yield

<r:yield />

This is a tag specific to layouts. It indicates where the template will insert its data. What are layouts & r:yield?

See also: <r:content_for />, <r:content />& the page on Yielding content to other places within the DOM and Layout.

Attribute options

name="content-name" - This allows you to specify which content you are yielding.

Example:

<!-- In layout file: -->
<r:yield name="page_js">
  <!-- this is where the content will be displayed -->
  <r:content />
</r:yield>
<!-- In template file: -->
<r:content_for name="page_js">
  <!-- Your content goes here -->
</r:content_for>

{{ content_for }}

This is a tag specific to Layouts. It indicates where the template will insert its data. What are Layouts, r:yield & TEMPLATE_CONTENT?

Also read our page on yielding content to other places within the DOM and Layout.

This tag is particularly useful for including specific CSS or JavaScript files in a template or partial and inserting them in the <head> or just before the closing </body> tag (or anywhere in your layout you like).

Attribute options

This tag doesn't have any attributes associated with it; however, it does require a name in quotes ("content-name") directly after the tag.

Example

Add this to your Layout (eg: default.html):

{{ content_for.page_js }}  <!-- 👈 This is where the content will output in your Layout. -->

And add to your template or partial:

{% content_for "page_js" %}
  <!-- Your content goes here -->
{% endcontent_for %}

Note: page_js can be any name (eg: bears, flying-monkeys, headerExtraContent, etc). If you change it in the {% content_for %} tag, make sure you also change it in the {{ content_for }} tag in your layout.

What's the difference between {{ content_for }} and {{ __TEMPLATE_CONTENT__ }}?

{{ __TEMPLATE_CONTENT__ }} is a special tag that tells CleanSlate where to output the data from your template (eg: frontpage.html or backpage.html). When you create a page in the CleanSlate UI, users have the ability to select a template. The content from that template will be output into your layout through this tag.

{{ content_for }} on the other hand accepts any content you feed it and can be placed anywhere in your Layout. It has nothing to do with the CleanSlate UI and will only output content you specify in your template's code. Think of it as a more flexible {{ __TEMPLATE_CONTENT__ }} tag that you feed code to in your templates.

To learn more about this, read What are Layouts & r:yield? and yielding content to other places within the DOM and Layout.

Last updated on March 16, 2021.

We welcome all questions, feedback and bug reports. If you're having an issue, we usually need the following information:

  • A brief description of the issue
  • A link to the page where you saw the issue
  • Screenshots that illustrate the problem - How do I take a screenshot?

Kindly email CleanSlate@mail.wvu.edu for help or use the form on the request help page.