This package has been deprecated

Author message:

Moved to GitHub Packages

@zestia/ember-twitter-entities

5.3.0 • Public • Published

@zestia/ember-twitter-entities

Latest npm release Ember Observer

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

Demo

https://zestia.github.io/ember-twitter-entities

Notes

  • Supported entity types are: hashtags, media, urls, user_mentions, symbols. Basically any entity which has an indices property and occurs in the tweet text. So this excludes polls.

Example

Given the following:

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

The addon will render:

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

...using the built in components for each entity type.

TwitterEntities

Arguments

@text

Required. The text to parse to find entities within.

@entities

Required. An object of entities that includes information about where each entity appears within the @text.

@Url

Optional. The component that will be used to display a URL entity.

@Hashtag

Optional. The component that will be used to display a hashtag entity.

@UserMention

Optional. The component that will be used to display a user mention entity.

@Media

Optional. The component that will be used to display a media entity.

@Symbol

Optional. The component that will be used to display a symbol entity.

API

entity

Each component receives the entity so it can be displayed however you wish.

HTML in tweets

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

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

Dependencies (3)

Dev Dependencies (37)

Package Sidebar

Install

npm i @zestia/ember-twitter-entities

Weekly Downloads

1

Version

5.3.0

License

MIT

Unpacked Size

12.6 kB

Total Files

22

Last publish

Collaborators

  • philliphaines
  • amk221