Skip to main content

highlight

string | highlight: string
returns string

Wraps all instances of a specific string, within a given string, with an HTML <strong> tag with a class attribute of highlight.

{% for item in search.results %}
{% if item.object_type == 'product' %}
{{ item.description | highlight: search.terms }}
{% else %}
{{ item.content | highlight: search.terms }}
{% endif %}
{% endfor %}

Output

This is a <strong class="highlight">love</strong> potion.
Was this page helpful?