I'm trying to pass a variable value from an include into a template file. The variable is imageRatio. Within this include file I have the logic which sets the right image ratio. My goal with this is to have one place to set the logic which I can reuse in different templates - I'm trying to keep the code DRY.
When I do the below get an error saying Variable "imageRatio" does not exist. What am I doing wrong?
The Main Template
{# The Image Ratio include #}
{% include '_includes/builders/images/imageVariants' %}
{# Create an Image Variant #}
{% set optimizedImages = block.image.one()[imageRatio] %}
{% include '_includes/builders/images/imageOptimize' %}
Image Ratio Include
{# Define Image Varient #}
{% if block.imageRatio == 'thumb' %}
{% set imageRatio = 'imageVariantsThumb' %}
{% elseif block.imageRatio == '16by9' %}
{% set imageRatio = 'imageVariants16by9' %}
{% elseif block.imageRatio == '3by2' %}
{% set imageRatio = 'imageVariants3by2' %}
{% endif %}