Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@zestia/ember-twitter-entities

4.0.0 • Public • Published

@zestia/ember-twitter-entities

This Ember CLI addon parses Twitter Entities from the Twitter API and renders a them as Ember Components.

Installation

ember install @zestia/ember-twitter-entities

Notes

This addon requires the Babel Polyfill to correctly handle emojis.

Example

Given the following:

entities: {
  urls: [{
    url: 'https://t.co/emberjs',
    display_url: 'emberjs.com',
    indices: [6, 17]
  }],
  hashtags: [],
  user_mentions: [],
  media: []
}
<TwitterEntities
  @text="visit emberjs.com"
  @entities={{this.entities}}
/>

The addon will render:

visit <a href="http://t.co/emberjs">emberjs.com</a>

Customising

You can customise what components are used to render each type of entity:

<TwitterEntities
  @text={{this.tweet}}
  @entities={{this.entities}}
  @urlComponent={{component "x-link" target="_blank"}}
  @hashtagComponent="hash-tag"
  @userMentionComponent="user-mention"
  @mediaComponent="x-gallery/image"
/>

HTML in tweets

If the tweet you are rendering is already encoded, flag it as html-safe to prevent double encoding.

const tweet = 'This tweet contains &lt;br&gt; HTML';
this.set('text', htmlSafe(tweet));
<TwitterEntities @text={{this.text}} />
Outputs:    This tweet contains <br> HTML
Instead of: This tweet contains &lt;br&gt; HTML

Install

npm i @zestia/ember-twitter-entities

DownloadsWeekly Downloads

77

Version

4.0.0

License

MIT

Unpacked Size

10.3 kB

Total Files

23

Last publish

Collaborators

  • avatar
  • avatar
  • avatar