Skip to content

Commit c95d9d6

Browse files
committed
Use context rather than arg in README examples
1 parent 3aef7f6 commit c95d9d6

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

README.markdown

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ template. Here's an example, which assumes that your objects have a URL
5555
embedded 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

6262
var 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

6565
var template = Handlebars.compile(source);
6666
template(context);
@@ -130,12 +130,12 @@ When calling a helper, you can pass paths or Strings as parameters. For
130130
instance:
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

137137
var 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

140140
var template = Handlebars.compile(source);
141141
template(context);

0 commit comments

Comments
 (0)