@zestia/ember-wrap-urls

6.1.0 • Public • Published

@zestia/ember-wrap-urls

Latest npm release GitHub Actions Ember Observer

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 @zestia/ember-wrap-urls

Demo

https://zestia.github.io/ember-wrap-urls/

Example

Given the following:

<WrapUrls @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 built in components:

  • wrap-urls/url
  • wrap-urls/link

By default, URLs will be rendered using wrap-urls/url

You can set @Url to change which component is used to render each URL:

<WrapUrls
  @Url={{component "wrap-urls/link"}}
  @text="Visit http://example.com"
/>

Will result in:

Visit <a class="wrapped-url-link" href="http://example.com">http://example.com</a>

Customising

Specify your own @pattern to use for finding hyperlinks, and your own @Url to customise how they are rendered.

<WrapUrls
  @Url={{component "mailto"}}
  @text={{this.text}}
  @pattern={{this.mailtoPattern}}
/>

In your component's template you will have access to:

{{@url.string}}
{{@url.start}}
{{@url.end}}

Install

npm i @zestia/ember-wrap-urls

DownloadsWeekly Downloads

35

Version

6.1.0

License

MIT

Unpacked Size

9.55 kB

Total Files

15

Last publish

Collaborators

  • connorhome
  • philliphaines
  • amk221