forked from janl/mustache.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If a section key returns a function, it will be called and passed both the unrendered block of text and a renderer convenience function. Given this JS: "name": "Tater", "bolder": function() { return function(text, render) { return "<b>" + render(text) + '</b>' } } And this template: {{#bolder}}Hi {{name}}.{{/bolder}} We'll get this output: <b>Hi Tater.</b> As you can see, we're pre-processing the text in the block. This can be used to implement caching, filters (like syntax highlighting), etc. You can use `this.name` to access the attribute `name` from your view.
- Loading branch information
Showing
6 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# mustache.js Changes | ||
|
||
## 0.3.0 (??-??-????) | ||
* Added higher order sections. | ||
|
||
|
||
## 0.2.3 (28-03-2010) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{#bolder}}Hi {{name}}.{{/bolder}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var higher_order_sections = { | ||
"name": "Tater", | ||
"helper": "To tinker?", | ||
"bolder": function() { | ||
return function(text, render) { | ||
return "<b>" + render(text) + '</b> ' + this.helper; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<b>Hi Tater.</b> To tinker? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters