@@ -55,12 +55,12 @@ template. Here's an example, which assumes that your objects have a URL
5555embedded in them, as well as the text for a link:
5656
5757``` js
58- Handlebars .registerHelper (' link_to' , function (context ) {
59- return " <a href='" + context .url + " '>" + context .body + " </a>" ;
58+ Handlebars .registerHelper (' link_to' , function () {
59+ return " <a href='" + this .url + " '>" + this .body + " </a>" ;
6060});
6161
6262var context = { posts: [{url: " /hello-world" , body: " Hello World!" }] };
63- var source = " <ul>{{#posts}}<li>{{{link_to this }}}</li>{{/posts}}</ul>"
63+ var source = " <ul>{{#posts}}<li>{{{link_to}}}</li>{{/posts}}</ul>"
6464
6565var template = Handlebars .compile (source);
6666template (context);
@@ -130,12 +130,12 @@ When calling a helper, you can pass paths or Strings as parameters. For
130130instance:
131131
132132``` js
133- Handlebars .registerHelper (' link_to' , function (title , context ) {
134- return " <a href='/posts" + context .url + " '>" + title + " !</a>"
133+ Handlebars .registerHelper (' link_to' , function (title ) {
134+ return " <a href='/posts" + this .url + " '>" + title + " !</a>"
135135});
136136
137137var context = { posts: [{url: " /hello-world" , body: " Hello World!" }] };
138- var source = ' <ul>{{#posts}}<li>{{{link_to "Post" this }}}</li>{{/posts}}</ul>'
138+ var source = ' <ul>{{#posts}}<li>{{{link_to "Post"}}}</li>{{/posts}}</ul>'
139139
140140var template = Handlebars .compile (source);
141141template (context);
0 commit comments