Conditional statement/variable within partial call

I've tried using the following code, to provide pass in a conditional 'sizes' variable for a responsive image partial — unfortunately this doesn't work.

{{ partial src="elements/image"
    class="flex pointer-events-none" 
    {{ if image_width == "3/12" }}
    sizes="(min-width: 768px) 25vw, 90vw"
    {{ elseif image_width == "4/12" }}
    sizes="(min-width: 768px) 30vw, 90vw"
    {{ elseif image_width == "5/12" }}
    sizes="(min-width: 768px) 40vw, 90vw"
    {{ /if }}

Since it isn't possible to assign a temporary variable in Statamic, what would be the cleanest way to achieve this? I realise I code repeat the partial call within each if statement, but I'd love to find a cleaner, more dry method if it exists!

Thanks for any help you can provide.


>>>>>>> Unanswered <<<<<<<
2 Replies