Reputation: 9568
I need to add a link that is dynamically generated in the template by appending a base url to a user id i.e I need something like 'http://google.com/?user_id=123'. How do I go about appending the base url to the user id in the href.
I need something that achieves the below result
<a href="base_url + {{user.id}}"> Visit User </a>
Upvotes: 1
Views: 6868
Reputation: 9568
Ended up with creating a Handlebars helper
Ember.Handlebars.helper('dynamicLink', function (username, id, label) {
var link = '<a target="_blank" href="http://xxxxxx'+
id + '/?username=' + username +'">' + label + '</a>';
return new Em.Handlebars.SafeString(link);
});
and then this in the templates
{{dynamicLink user.username 1 "XXXX"}}
Upvotes: 0
Reputation: 337
This problem doesn't require a Helper. You could do the following:
<a href="http://google.com/?user_id={{user.id}}"> Visit User </a>
Upvotes: 3