Skip to content

Instantly share code, notes, and snippets.

@amk221
Last active June 10, 2019 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amk221/8d3d59ef47819ddfb68cf606cca3c53e to your computer and use it in GitHub Desktop.
Save amk221/8d3d59ef47819ddfb68cf606cca3c53e to your computer and use it in GitHub Desktop.
ember style attribute helpers
<div style={{html-safe (concat "background-color: " (escape this.userColour))}}>
</div>
import Ember from 'ember';
import { helper } from '@ember/component/helper';
const { escapeExpression } = Ember.Handlebars.Utils;
/**
* This helper escapes a value
*
* Example:
* {{escape "<b>Hi!</b>"}}
*
* ...results in '&lt;Hi!&gt;'
*
*/
export default helper(function(args) {
return escapeExpression(...args);
});
import { helper } from '@ember/component/helper';
import { htmlSafe } from '@ember/string';
/**
* This helper is a replacement for triple curlies.
*
* Example:
* {{html-safe "<b>foo</b>"}}
*
*/
export default helper(function(args) {
return htmlSafe(...args);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment