How to use the @ember/string.isHTMLSafe function in @ember/string

To help you get started, we’ve selected a few @ember/string examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lstrrs / ember-line-clamp / addon / components / line-clamp.js View on Github external
_getLines() {
    const lines = [];
    const numLines = this.get('lines');
    const text = this.get('text') || '';
    const textToTruncate = isHTMLSafe(text) ? this._unescapeText(text) : text;
    const formattedText = this.stripText ? this._stripBrTags(textToTruncate) : this._convertBrTags(textToTruncate);
    const textLines = formattedText.split('\n').map(line => line.trim().split(' '));
    let didTruncate = true;

    const ellipsisWidth = this._getEllipsisWidth();

    for (let line = 1; line <= numLines; line += 1) {
      const textWords = textLines[0];

      // handle new line -- ???
      if (textWords.length === 0) {
        lines.push({
          newLine: true,
        });
        textLines.shift();
        line -= 1;
github adopted-ember-addons / ember-notify / addon / index.js View on Github external
show(type, text, options) {
    // If the text passed is `SafeString`, convert it
    if (isHTMLSafe(text)) {
      text = text.toString();
    }

    if (typeof text === 'object') {
      options = text;
      text = null;
    }

    let message = Message.create(assign({
      text: text,
      type: type
    }, options));

    if (this.target) {
      this.target.show(message);
    } else {
github jasonmit / ember-i18n-cp-validations / addon / validators / messages.js View on Github external
function isSafeString(input) {
  return typeof isHTMLSafe === 'function' ? isHTMLSafe(input) : input instanceof Handlebars.SafeString;
}
github Deveo / ember-emojione / addon / helpers / inject-emoji.js View on Github external
compute([inputStr], overrideOptions) {
    if (!inputStr) {
      return '';
    }

    const currentOptions         = this._mergeOptions(overrideOptions);
    const initialEmojiOneOptions = this._captureEmojiOneInitialState();
    const isInputHtmlSafe        = isHTMLSafe(inputStr);

    this._applyOptionsToEmojiOne(currentOptions.emojione);
    const result = this._injectEmoji(inputStr.toString(), currentOptions);
    this._applyOptionsToEmojiOne(initialEmojiOneOptions);

    return isInputHtmlSafe
      ? htmlSafe(result)
      : result;
  },
github offirgolan / ember-cp-validations / addon / utils / utils.js View on Github external
export function unwrapString(s) {
  if (isHTMLSafe(s)) {
    return s.toString();
  }

  return s;
}
github romulomachado / ember-cli-string-helpers / addon / helpers / humanize.js View on Github external
export function humanize([string]) {
  if (isHTMLSafe(string)) {
    string = string.string;
  }

  if (string === undefined || string === null) {
    return '';
  }

  let result = string.toLowerCase().replace(regex, replacement);
  return result.charAt(0).toUpperCase() + result.slice(1);
}
github HospitalRun / hospitalrun-frontend / app / mixins / filter-list.js View on Github external
filteredBy.forEach((filterValue, filterBy) => {
        let itemValue = listItem.get(filterBy);
        if (!isEmpty(filterValue)) {
          if (isHTMLSafe(filterValue)) {
            filterValue = filterValue.toString();
          } else if (filterValue instanceof Date) {
            filterValue = filterValue.getTime();
          }
          if (isHTMLSafe(itemValue)) {
            itemValue = itemValue.toString();
          } else if (itemValue instanceof Date) {
            itemValue = itemValue.getTime();
          }
          if (itemValue !== filterValue) {
            includeRecord = false;
          }
        }
      });
      return includeRecord;
github hummingbird-me / hummingbird-client / lib / kitsu-shared / addon / components / read-more.js View on Github external
truncatedText: computed('text', 'length', 'isHTML', 'maxLines', function() {
    const options = { html: this.get('isHTML'), maxLines: this.get('maxLines') };
    const text = this.get('text');
    if (!text) { return null; }

    const string = isHTMLSafe(text) ? text.string : text;
    return htmlSafe(clip(string, this.get('length'), options));
  }).readOnly(),

@ember/string

A set of utilities to transform strings

MIT
Latest version published 5 months ago

Package Health Score

73 / 100
Full package analysis

Similar packages