Konafets / antlers-idea

Adds support for Antlers, the templating language of Statamic
MIT License
16 stars 1 forks source link

Parse Antlers inside a parameter string value of another Antlers region. #139

Open Konafets opened 1 year ago

Konafets commented 1 year ago

Antlers support the concept of interpolated statements, which means, one can insert Antlers into a Antlers node:

{{ items = {collection:products sort="rating:desc" limit="5"} }}

While this already works, I discovered a special case, where an Antlers switch statement is inserted into the string value of a class attribute:

{{ svg
    :src="type"
    alt=""
    aria-hidden="true"
    class="
        h-5 w-5 fill-current motion-safe:transition-colors
        { switch(
            (type == 'success') => 'text-green-800',
            (type == 'notice') => 'text-yellow-800',
            (type == 'error') => 'text-red-800',
            () => 'text-gray-800'
        )}
    "
}}