Removing tag pairs from Antlers tags so logic still works with runtime parser #9113
-
Hello, I'm in the process of trying to switch a project from the legacy parser to the runtime parser. I've run into an error (in several files) that's preventing hundreds of pages from rendering:
Here's an example that works with the legacy parser but gives that error with the runtime parser: {{ if total_results === 1 }}
{{ partial:globals/images/hero_image
{{ if landing_page_row_item_photo }}
:image="landing_page_row_item_photo"
{{ elseif landing_page_row_item_entry:hero_image }}
:image="landing_page_row_item_entry:hero_image"
...another elseif...
{{ /if }}
custom_classes="m-0" }}
{{ else }}
...similar, but with more params that all cases share...
{{ /if }} The {{ if total_results === 1 }}
{{ if landing_page_row_item_photo }}
{{ partial:globals/images/hero_image
:image="landing_page_row_item_photo"
custom_classes="m-0" }}
{{ elseif landing_page_row_item_entry:hero_image }}
{{ partial:globals/images/hero_image
:image="landing_page_row_item_entry:hero_image"
custom_classes="m-0" }}
...another elseif...
{{ /if }}
{{ else }}
...similar, but with more params that all cases share...
{{ /if }} —but I'd like to avoid repeating code if possible. (I chose a shorter example to show here. Other instances of ours would have a lot more repetition.) I suspect there's a better way I'm not aware of. Do you have any suggestions? (I tried a Thanks very much in advance for any pointers. Bruce |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You could set variables and pass them in. {{ image = landing_page_row_item_photo ?? landing_page_row_item_entry:hero_image ?? "fallback" }}
{{ partial:globals/images/hero_image :image="image" custom_classes="m-0" }} |
Beta Was this translation helpful? Give feedback.
You could set variables and pass them in.