KOGI
KOGI

Reputation: 3989

SafeStrings when using Ember's bindAttr?

This is highly simplified, but I have something like the following:

<img src="www.example.com/image.jpg" {{bindAttr alt="view.altText"}} />

The altText binding comes from a computed property in the view which returns an HTML character like &#x54;, but then either Ember or Handlebars (not sure) escapes it for output and what I end up seeing in the code is &amp;#x54; which displays in the browser as, literally "&#x54;" instead of the proper HTML character.

In the computed property, I tried return new Handlebars.SafeString( '&#x54;' ), but that just threw an error about expecting a string, not an object.

So how do I prevent this?

Update: Here's a github issue on the matter. Currently no additional info, but it may get updated before this thread does.

Upvotes: 4

Views: 663

Answers (1)

Neikos
Neikos

Reputation: 1980

Handlebars escapes values between {{ }} use {{{ }}} to show output unescaped strings.

Source: http://handlebarsjs.com/

Upvotes: 4

Related Questions