--- title: Migrate to Liquid's rigid parser description: >- Tips on migrating your theme or theme app extension to Liquid's rigid error mode. source_url: html: 'https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration' md: 'https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md' --- ExpandOn this page * [Expected end\_​of\_​string but found pipe](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-end_of_string-but-found-pipe) * [Expected end\_​of\_​string but found comparison](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-end_of_string-but-found-comparison) * [Expected end\_​of\_​string but found colon](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-end_of_string-but-found-colon) * [Expected end\_​of\_​string but found id](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-end_of_string-but-found-id) * [Expected colon but found end\_​of\_​string](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-colon-but-found-end_of_string) * [Expected colon but found comma](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-colon-but-found-comma) * [Unexpected characters](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#unexpected-characters) * [\[:end\_​of\_​string\] is not a valid expression](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#end_of_string-is-not-a-valid-expression) # Migrate to Liquid's rigid parser Beginning with v5.9.0 Liquid ships with a new rigid error mode. The current lax error mode that we use accepts, but evaluates incorrectly, code that we wish worked. In order to evolve the language, we need to start refusing code that we want to work in the future as well as malformed code. As an example, instead of accepting `assign x = false or true` and evaluating `x` to be `false`, we'll tell you that this code is unparseable. This'll allow us to change this behavior down the line to actually accept `assign x = false or true` and correctly evaluating it to `true`. In the example below, the existing parser would swallow the syntax error caused by trying to assign a logical expression to a variable and would never render `Important content`. ## snippets/example.liquid ```liquid {% assign x = false or true} {% if x %} Important content {% endif %} ``` We've put together a list of common errors we've seen across themes and theme app extensions to help the transition: *** ## Expected end\_​of\_​string but found pipe ### Filters in render tags Using filters outside of variable output, assign and the echo tag throws a syntax error: ## snippets/example.liquid ```liquid {% render 'image', image: image, alt: image.alt | escape %} ``` Fix by pulling the filter outside of the render tag and into its own variable: ## snippets/example.liquid ```liquid {% assign alt_text = image.alt | escape %} {% render 'image', image: image, alt: alt_text %} ``` *** ## Expected end\_​of\_​string but found comparison ### Conditional expressions in render tags Using conditional expressions as a value for a render argument throws a syntax error: ## snippets/example.liquid ```liquid {% render 'product-card', product: product, show_description: settings.x or settings.y, %} ``` Fix by wrapping the render tag with the conditional expression: ## snippets/example.liquid ```liquid {% if settings.x or settings.y %} {% render 'product-card', product: product, show_description: true, %} {% endif %} ``` *** ## Expected end\_​of\_​string but found colon ### Using `with` with key value pairs You can pass a single object to a snippet using the `with` parameter but also including a key value pair causes a syntax error: ## snippets/example.liquid ```liquid {% render 'icon' with style: 'lock' %} ``` Fix by removing `with`: ## snippets/example.liquid ```liquid {% render 'icon', style: 'lock' %} ``` Another version of this error you might see is raised as `[:colon, ":"] is not a valid expression` which you'll see if you use a colon immediately after `with`. Similarly to above, fix by removing `with:`: ## snippets/example.liquid ```diff - {% render 'icon', with: style: 'lock' %} + {% render 'icon', style: 'lock' %} ``` If you want to keep the behavior of `with` (which in the error example above assigns the value of `style` to `icon`, [see documentation](https://shopify.dev/docs/api/liquid/tags/render#render-with) for more details) then you can specify it like this: ## snippets/example.liquid ```liquid {% assign style = 'lock' %} {% render 'icon' with style %} ``` ### Malformed arguments in render tag Missing a value for the `responsive` attribute: ## snippets/example.liquid ```liquid {% render 'image', lazyload: lazyload, responsive: width: 500 %} ``` Fix by adding a value for `responsive`: ## snippets/example.liquid ```liquid {% render 'image', lazyload: lazyload, responsive: true, width: 500 %} ``` *** ## Expected end\_​of\_​string but found id ### Logical operators in variable assignments Logical operators can only be used in `if` statements. The following throws a syntax error: ## snippets/example.liquid ```liquid {% liquid assign x = settings.y or settings.z if x # logic endif %} ``` Fix by moving the conditional expression into the `if` statement: ## snippets/example.liquid ```liquid {% liquid if settings.y or settings.z # logic endif %} ``` ### Logical operators in case statements Just like variables, case statements can't use logical operators: ## snippets/example.liquid ```liquid {% liquid case template.name when 'product' # product logic when 'collection' and settings.x # collection logic else # all other templates endcase %} ``` Depending on the scenario you might need to rework your business logic but the example above could be refactored to be like this: ## snippets/example.liquid ```liquid {% liquid case template.name when 'product' # product logic when 'collection' if settings.x # collection logic endif else # all other templates endcase %} ``` *** ## Expected colon but found end\_​of\_​string ### Malformed arguments passed to render tag ## snippets/example.liquid ```liquid {% render 'image', lazyload: lazyload, responsive %} ``` Fix by adding a value for `responsive`: ## snippets/example.liquid ```liquid {% render 'image', lazyload: lazyload, responsive: true %} ``` *** ## Expected colon but found comma ### Malformed arguments passed to render tag ## snippets/example.liquid ```liquid {% render 'related-products', product, collection %} ``` Variables passed to a snippet need to be formatted as key value pairs: ## snippets/example.liquid ```liquid {% render 'related-products', product: product, collection: collection %} ``` *** ## Unexpected characters This is an all encompassing error that can sometimes be hard to parse where the exact issue is. In most cases the problem is a typo but the line number on the error should help point you to the exact spot. Provided are some common examples we've seen but this isn't an exhaustive list: ### Conditional expressions using `&&` and `||` instead of `and` and `or` Conditional expressions in Liquid use `and` and `or`. Using `&&` and `||` throws a syntax error: ## snippets/example.liquid ```liquid {% liquid if responsive && settings.x || settings.y render 'responsive-image', image: image endif %} ``` Fix by using Liquid's boolean operators: ## snippets/example.liquid ```liquid {% liquid if responsive and settings.x or settings.y render 'responsive-image', image: image endif %} ``` ### Conditional expressions using parentheses Using parentheses to group conditional expressions throws a syntax error: ## snippets/example.liquid ```liquid {% liquid if responsive and (settings.x or settings.y) render 'responsive-image', image: image endif %} ``` Fix by removing the parentheses (and read the [documentation](https://shopify.dev/docs/api/liquid/basics#order-of-operations) on the order in which Liquid parses conditional expressions): ## snippets/example.liquid ```liquid {% liquid if responsive and settings.x or settings.y render 'responsive-image', image: image endif %} ``` ### Invalid expressions used in case statement The following results in `Liquid syntax error (line 3): Unexpected character =`: ## snippets/example.liquid ```liquid {% liquid case media.preview_image.width when => 550 assign media_largest = media.preview_image | image_url: width: 550 | append: '550w' when => 1100 assign media_largest = media.preview_image | image_url: width: 1100 | append: '1100w' # etc... endcase %} ``` To fix this remove the `=>`: ## snippets/example.liquid ```liquid {% liquid case media.preview_image.width when 550 assign media_largest = media.preview_image | image_url: width: 550 | append: '550w' when 1100 assign media_largest = media.preview_image | image_url: width: 1100 | append: '1100w' # etc... endcase %} ``` ### Comments must be written on their own line The following results in `Liquid syntax error (line 5): Unexpected character #`: ## snippets/example.liquid ```liquid {% liquid case media.preview_image.width when 550 assign media_largest = media.preview_image | image_url: width: 550 | append: '550w' when 1100 # this is a comment about this size assign media_largest = media.preview_image | image_url: width: 1100 | append: '1100w' # etc... endcase %} ``` To fix this remove the `=>`: ## snippets/example.liquid ```liquid {% liquid case media.preview_image.width when 550 assign media_largest = media.preview_image | image_url: width: 550 | append: '550w' when 1100 # this is a comment about this size assign media_largest = media.preview_image | image_url: width: 1100 | append: '1100w' # etc... endcase %} ``` *** ## `[:end_of_string]` is not a valid expression ### Malformed arguments passed to render tag ## snippets/example.liquid ```liquid {% render 'icon', style: %} ``` Fix by adding a value for `style:`: ## snippets/example.liquid ```liquid {% render 'icon', style: 'lock' %} ``` *** * [Expected end\_​of\_​string but found pipe](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-end_of_string-but-found-pipe) * [Expected end\_​of\_​string but found comparison](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-end_of_string-but-found-comparison) * [Expected end\_​of\_​string but found colon](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-end_of_string-but-found-colon) * [Expected end\_​of\_​string but found id](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-end_of_string-but-found-id) * [Expected colon but found end\_​of\_​string](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-colon-but-found-end_of_string) * [Expected colon but found comma](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#expected-colon-but-found-comma) * [Unexpected characters](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#unexpected-characters) * [\[:end\_​of\_​string\] is not a valid expression](https://shopify.dev/docs/storefronts/themes/tools/rigid-liquid-migration.md#end_of_string-is-not-a-valid-expression)