Feature request: Url formatter
alfonsobries opened this issue · comments
Create a filter to convert string to html link
I thinking in something like that
{{ 'http://www.site.com' | morph-url(target="_blank") )}} <!-- Returns <a href="http://www.site.com">http://www.site.com</a>
{{ 'me@site.com' | morph-url(is_email = true) )}} <!-- Returns <a href="mailto: me@site.com">me@site.com</a>
(Or better an easy way to create custom filters)
Hi @alfonsobries thanks for your suggestion. However I need to clarify your idea. What I understand is that you want to convert any link and/or email to a clickable <a>
tag?
Say "my website is http://foo.com" will become "my website is foo.com"? I don't think filters are designed to do that.
As a suggestion you can do this in a component to automatically convert links to <a>
tags.
Yes, exactly, sometimes you have some url from, for example an user profile and a common task is make it clickeable:
So normally i make something like this:
<p>User website: <a :href="user.website" target="_blank">{{ user.website }}</a></p>
So wouldn't be better something like:?
<p>User website: {{ user.website | morph-url(target="_blank") }}</p>
Also some configuration data to make them clickeable with the "mailto:" prefix, or open in blank page.
@alfonsobries I was thinking we can create a directive
instead of filter
that will do this. Just give me some time to work around on it.
Sure!, dont worry too much is just an idea
@alfonsobries it's actually a good idea. Thanks!
I'll see if I can start working on this.
@alfonsobries It's here. :)
@jofftiquez great!