1.0.14 • Published 8 years ago
ember-wrap-urls v1.0.14
ember-wrap-urls
This Ember addon takes some text, which may or may not contain URLs and renders the text and each URL as an Ember component.
Installation
ember install ember-wrap-urlsExample usage
Given the following:
{{wrap-urls text='Check out my link: http://example.com'}}Will render:
Check out my link <span class="wrapped-url">http://example.com</span>Built in components
This addon comes with two extra components:
wrap-urls/urlwrap-urls/link
By default, URLs will be rendered using wrap-urls/url
You can set component to change which component is used to render each URL:
{{wrap-urls text='Visit http://example.com' component='wrap-urls/link'}}Will result in:
Visit <a class="wrapped-url-link" href="http://example.com">http://example.com</a>To send in your own attributes:
{{wrap-urls
text='Visit http://example.com'
component=(component 'wrap-urls/link' target="_blank")}}Customising
Specify your own component to customise how URLs are rendered:
{{wrap-urls text=text component=(component 'my-tooltip')}}You change the pattern used to find hyperlinks:
import WrapUrlsComponent from 'ember-wrap-urls/components/wrap-urls';
WrapUrlsComponent.reopenClass({
regex: /yourRegexGoesHere/g
});