Search code examples
htmlcsstemplatesgoogle-closure-templatessoy-templates

How to add multiple CSS classes to HTML node in Closure template (soy)?


In a template I need to assign more than one CSS class to a div.

However, when I try something like the following, the Closure compiler seems to wrap only the first class in quotation marks, resulting in the browser ignoring the rest.

<div class={foreach $cssClass in $cssClasses}{$cssClass} {/foreach}>...</div>

DOM result

I tried wrapping the whole thing in quotation marks (with and without {literal})... didn't do the trick.


Solution

  • Wrap class in quotations

    <div class="{foreach $cssClass in $cssClasses}{$cssClass} {/foreach}">...</div>