Skip to content
🐦 Renders entities from Twitter's API as Ember components
JavaScript HTML CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
addon
app
config
tests
vendor
.editorconfig
.ember-cli
.eslintignore
.eslintrc.js
.gitignore
.npmignore
.prettierignore
.prettierrc.js
.release-it.js
.stylelintignore
.stylelintrc.js
.template-lintrc.js
.travis.yml
.watchmanconfig
CHANGELOG.md
LICENSE.md
README.md
ember-cli-build.js
index.js
package-lock.json
package.json
testem.js

README.md

@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
You can’t perform that action at this time.