Skip to main content

r:select_html

<r:select_html />

A tag used to select specified HTML elements when looping through editable regions on pages via r:each.

Attribute Options

limit="3" - Number. Limits how many tags to return.

css_selector - String. Pass this attribute a CSS selector (eg: h2or .example). Separate multiple selectors with commas and spaces.

Example:

<r:select_html css_selector="img, p" limit="2">
  <r:article:content name="article-body" />
</r:select_html>
See an example of this in the CleanSlate Toolkit's Blog Index template.

{{ "<p>Hello world</p>" | select_html: css_selector: "p", limit: 1 }}

A Liquid Filter to select HTML from a string. This Filter is most often used when looping through content on pages via for loops.

Attribute options

css_selector - String. Pass this attribute any valid CSS selector (eg: h2 or .example). Separate multiple selectors with commas and spaces.

limit: 3 - Number. Limits how many tags to return.

Examples:

{{ "<p>Hello world</p><p>This is content</p>" | select_html: css_selector: "p", limit: 1 }}
<!-- Output: "<p>Hello world</p>" -->
<!-- Used within a `for` loop: -->
{{ article.content["article-body"] | select_html: css_selector: ".article-thumbnail, p", limit: 2 }}

See an example of this in the CleanSlate Toolkit's Blog Index template.

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.