Closed mschinis closed 5 years ago
Interestingly, my first attempt at this was a helper.
However, there were a couple of issues...
1) wrap-urls
is (usually) a dead-end. Therefore, being able to call it as a helper isn't useful. Consider:
ok
{{wrap-urls text=(truncate 'visit http://example.com' 19)}}
Which results in: visit <span class="ember-view url">http://exampl</span>
not ok
{{truncate (wrap-urls 'visit http://example.com') 19}}
Which could result in: visit <span class="
(However, it won't because span
is not an HTML string)
2) The result of calling wrap-urls
needs to contain components (not just plain HTML strings). Helpers don't have HTMLBars templates, so I opted for a Component.
It's probably possible to achieve using streams, which would be more performant - but I am unfamiliar with them.
I'd appreciate any help on the matter
http://exampl
, right?.import hbs from 'htmlbars-inline-precompile';
export function someHelper([component]) {
return hbs`{{${component}}}{{/${component}}}`;
}
export default Ember.Helper.helper(someHelper);
I haven't tried the above yet, but that should work.
I'll have a crack at it, later in the weekend and let you know how it goes :)
@mschinis
Hello,
It would be very interesting to see this addon in a helper format, so that you could use something like the following:
(some-other-helper (wrap-urls "hey check this cool product http://somethingcool.com"))