Ember: Ember.Handlebars.SafeString not working on production?


#1

Hi, I am developing ember-app using ember-cli

I have added following helper to display image from cloudinary by passing image-id

import Ember from "ember";
export default Ember.Handlebars.makeBoundHelper(function(value, options) {
  var html;
  if (value) {
    var image = value.split('/')[1];
    var version = value.split('/')[0];
    var tag = Ember.$.cloudinary.image(image, {
      version: version,
      height: options.hash['height'],
      width: options.hash['width'],
      class: 'current_image '+ (options.hash['className'] || ''),
      crop: (options.hash['width'] === 50 ? 'fill' : 'fit'),
      border: (options.hash['width'] === 50 ? '2px_solid_grey' : '0px_solid_grey'),
      id: value
    });
    html = tag[0].outerHTML;
  } else {
    html = '<img src="assets/images/default_item.jpg">';
  }
  return new Ember.Handlebars.SafeString(html);
});

And called it as follows {{image-tag image-id-value height=50 width=50}}

It works properly on local but not on production.

On production it just prints in html tag form

<img class="current_image " id="1407240543/i8dcew8455azhdvqbupy.png" src="<image-url>">

Can anyone pls help me to resolve this?


#2

Try using Ember.String.htmlSafe(html). It works in ember-cli 2.5