Socket
Book a DemoInstallSign in
Socket

ember-twitter-entities

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-twitter-entities

Renders Twitter Entities as Ember Components

latest
Source
npmnpm
Version
2.2.13
Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

ember-twitter-entities

       

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

Installation

ember install ember-twitter-entities

Notes

This addon requires the Babel Polyfill to correctly handle emojis.

Example usage

Given the following:

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

The addon will render:

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:

// 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 });
{{! 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.

{{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

{{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.

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

Keywords

ember-addon

FAQs

Package last updated on 02 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.