0

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.

Jan J
  • 13
  • 4

1 Answers1

1

Wrap class in quotations

<div class="{foreach $cssClass in $cssClasses}{$cssClass} {/foreach}">...</div>
mildog8
  • 2,030
  • 2
  • 22
  • 36
  • Beat me to the punch. – Ian Taylor Dec 20 '16 at 14:46
  • @IanTaylor The liberal surfer don't mess around! – mildog8 Dec 20 '16 at 14:47
  • Damnit! That worked. The reason why it didn't work before was, because I was storing `class={foreach $cssClass in $cssClasses}{$cssClass} {/foreach}` in a variable and then used this variable in the
    . Anyway... Thank you!
    – Jan J Dec 20 '16 at 15:01
  • Addition (can't edit): This was what I had: `{let $classesString} class="{foreach $cssClass in $cssClasses}{$cssClass} {/foreach}" {/let}` and then
    – Jan J Dec 20 '16 at 15:03