--- title: "Liquid filters: highlight" description: |- Wraps all instances of a specific string, within a given string, with an HTML `` tag with a `class` attribute of `highlight`. api_name: liquid source_url: html: https://shopify.dev/docs/api/liquid/filters/highlight md: https://shopify.dev/docs/api/liquid/filters/highlight.md --- # highlight ```oobleck string | highlight: string ``` returns [string](https://shopify.dev/docs/api/liquid/basics#string) Wraps all instances of a specific string, within a given string, with an HTML `` tag with a `class` attribute of `highlight`. ```liquid {% for item in search.results %} {% if item.object_type == 'product' %} {{ item.description | highlight: search.terms }} {% else %} {{ item.content | highlight: search.terms }} {% endif %} {% endfor %} ``` ##### Code ``` {% for item in search.results %} {% if item.object_type == 'product' %} {{ item.description | highlight: search.terms }} {% else %} {{ item.content | highlight: search.terms }} {% endif %} {% endfor %} ``` ##### Data ``` { "search": { "results": [ { "description": "", "object_type": "product" }, { "description": "", "object_type": "product" }, { "description": "", "object_type": "product" }, { "description": "", "object_type": "product" }, { "description": "This is a love potion.", "object_type": "product" }, { "description": "", "object_type": "product" } ], "terms": "love" } } ``` ## Output ```html This is a love potion. ```