Joe Fokker
Joe Fokker

Reputation: 43

Unable to specify multiple attributes in handlebar

I am having problem specifying multiple attributes in any class at all.

if I have a key:value like

{"class":"javascript handlebar-js"}

and use it like this <div class={{class}}><div>

it only spits out <div class="javascript"><div>

when I want <div class="javascript handlebar-js"><div>

Sometimes I have one class sometimes I have multiple classes Is there any other way to do this besides putting all classes inside an array and using a with + each statement to move through each class and cramping up my object with unnecessary arrays? Not that I am sure if using said method would work.

any help would be appreciated

Upvotes: 2

Views: 175

Answers (1)

Cybermaxs
Cybermaxs

Reputation: 24556

As said by Pointy, enclosed class definition into simple or doubles quotes.

Based upon this data ({"className":"javascript handlebar-js"}),

<div class="{{className}}"> </div> will produce <div class="javascript handlebar-js"></div>

<div class={{className}}> </div> will produce <div class="javascript" handlebar-js></div>

The two results will not be interpreted in the same way in the browser.

Upvotes: 1

Related Questions