# ember-twitter-entities

> Renders Twitter Entities as Ember Components

Latest version **2.2.13** (published 2017-12-02) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ember-twitter-entities
pnpm add ember-twitter-entities
yarn add ember-twitter-entities
bun add ember-twitter-entities
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.2.13 |
| Published | 2017-12-02 |
| First published | 2016-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Andrew Kirwin |
| Maintainers | amk221 |
| Keywords | ember-addon, twitter, entities, hashtag, user_mentions |

## Links

- npm: https://www.npmjs.com/package/ember-twitter-entities
- Repository: https://github.com/amk221/ember-twitter-entities
- Issues: https://github.com/amk221/ember-twitter-entities/issues
- npm.io page: https://npm.io/package/ember-twitter-entities

## Dependencies (2)

- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) 6.10.0
- [ember-cli-htmlbars](https://npm.io/package/ember-cli-htmlbars.md) 2.0.3

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 2.2.13 (latest) — 2017-12-02
- 2.2.11 — 2017-08-07
- 2.2.10 — 2017-07-12
- 2.2.9 — 2017-05-22
- 2.2.8 — 2017-05-18
- 2.2.7 — 2017-05-03
- 2.2.6 — 2017-05-02
- 3.0.0 — 2017-04-03
- 2.2.5 — 2017-01-24
- 2.2.2 — 2016-12-01
- 2.2.1 — 2016-11-29
- 2.2.0 — 2016-10-10
- 2.1.7 — 2016-07-28
- 2.1.6 — 2016-06-27
- 2.1.5 — 2016-06-23
- … 2 more at https://npm.io/package/ember-twitter-entities/versions

## README

# ember-twitter-entities

<a href="http://emberobserver.com/addons/ember-twitter-entities"><img src="http://emberobserver.com/badges/ember-twitter-entities.svg"></a> &nbsp; <a href="https://david-dm.org/amk221/ember-twitter-entities#badge-embed"><img src="https://david-dm.org/amk221/ember-twitter-entities.svg"></a> &nbsp; <a href="https://david-dm.org/amk221/ember-twitter-entities#dev-badge-embed"><img src="https://david-dm.org/amk221/ember-twitter-entities/dev-status.svg"></a> &nbsp; <a href="https://codeclimate.com/github/amk221/ember-twitter-entities"><img src="https://codeclimate.com/github/amk221/ember-twitter-entities/badges/gpa.svg" /></a> &nbsp; <a href="http://travis-ci.org/amk221/ember-twitter-entities"><img src="https://travis-ci.org/amk221/ember-twitter-entities.svg?branch=master"></a>

This Ember CLI addon parses [Twitter Entities](https://dev.twitter.com/overview/api/entities-in-twitter-objects) from the Twitter API and renders a them as Ember Components.

### Installation
```
ember install ember-twitter-entities
```

### Notes

This addon requires the [Babel Polyfill](https://github.com/babel/ember-cli-babel#polyfill) to correctly handle emojis.

### Example usage

Given the following:

```javascript
entities: {
  urls: [{
    url: 'https://t.co/emberjs',
    display_url: 'emberjs.com',
    indices: [6, 17]
  }],
  hashtags: [],
  user_mentions: [],
  media: []
}
```

```handlebars
{{twitter-entities text="visit emberjs.com" entities=entities}}
```

The addon will render:

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

### Customising

If you want to display twitter entities differently to the defaults, simply extend the component and provide a different template:

```javascript
// components/twitter-entity/media/component.js

import Component from 'ember-twitter-entities/components/twitter-entity/media';
import layout from './template';

export default Component.extend({ layout });
```
```handlebars
{{! components/twitter-entity/media/template.hbs }}

<img src={{entity.media_url_https}} width={{entity.sizes.thumb.w}} height={{entity.sizes.thumb.h}}>
```

Alternatively, you can customise the component on a per-instance basis.

```handlebars
{{twitter-entities text=tweet entities=entities
  url-component='tweet-url'
  hashtag-component='hash-tag'
  user-mention-component='user-mention'
  media-component='x-gallery/image'
```
You can even pass in a component

```handlebars
{{twitter-entities text=text entities=entities
  url-component=(component 'my-component' target='_blank')
```

### HTML in tweets

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

```javascript
const tweet = 'This tweet contains &lt;br&gt; HTML';
this.set('text', htmlSafe(tweet));
```

```handlebars
{{twitter-entities text=text}}
```

```
Outputs:    This tweet contains <br> HTML
Instead of: This tweet contains &lt;br&gt; HTML
```

---
_Source: https://npm.io/package/ember-twitter-entities · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
