copenndthagen
copenndthagen

Reputation: 50732

SyntaxError: unterminated string literal (Underscore templates)

I am using Underscore templates and am passing values to my template as below;

{
    title:  self.options.title,
    subtitle:   self.options.subtitle,
    fieldVal:   self.options.fieldVal,
    fieldAttr: self.options.fieldAttr
}

And I am using the same inside my html template as below;

<textarea name="<%= fieldAttr.fieldName %>" id="<%= fieldAttr.fieldName %>" <%= fieldAttr.readonly == false ? 'disabled' : '' %> <%= fieldAttr.dataModelId != undefined ? "data-model-id='" + fieldAttr.dataModelId + '" : "" %> ><%= fieldVal %></textarea>

I am getting error SyntaxError: unterminated string literal

What am I doing wrong?

Upvotes: 0

Views: 5619

Answers (1)

James Donnelly
James Donnelly

Reputation: 128791

You're missing an open double quote. You have this:

..."data-model-id='" + fieldAttr.dataModelId + '"

Which should be this:

..."data-model-id='" + fieldAttr.dataModelId + "'"

Upvotes: 1

Related Questions