EmberJS - Escaping HTML Content



You can escape the HTML tags while displaying the result.

Syntax

export default Ember.Helper.helper(function(params) {
   //code here
}

Example

The example given below will escape the HTML tags. Create a new helper eschtmlcontent and add the following code to it −

import Ember from 'ember';

export default Ember.Helper.helper(function(param) {
   return Ember.String.htmlSafe(`<i><b>${param}</b></i>`);
});

Open the index.hbs file and write the following code −

Hello...Welcome to {{eschtmlcontent "Tutorials-Point"}}
{{outlet}}

Output

Run the ember server; you will receive the following output −

Ember.js Template Escape HTML Content
emberjs_template.htm
Advertisements