Created
February 14, 2015 05:02
-
-
Save tkdn/58ddbf1965e341b94152 to your computer and use it in GitHub Desktop.
Assemble - Handlebars.js でヘルパーからオブジェクトを参照する ref: http://qiita.com/tkdn/items/499d253c0c71ebdaf56b
This file contains hidden or 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
| module.exports.register = function (Handlebars, options, params) { | |
| 'use strict'; | |
| Handlebars.registerHelper('foo', function(str) { | |
| return str; | |
| }); | |
| }; |
This file contains hidden or 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
| Handlebars.registerHelper('buz', function(str1, str2) { | |
| var value = ""; | |
| for(i=0;this.pages.length>i;i++){...} | |
| return val; | |
| }); |
This file contains hidden or 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
| {{#each pages}} | |
| <li>{{dest}}</li> | |
| {{/each}} |
This file contains hidden or 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
| date: "2015-02-14" | |
| title: "valentine's day" |
This file contains hidden or 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
| {{#each pages}} | |
| <li>{{dest}} - {{../title}}</li> | |
| {{/each}} |
This file contains hidden or 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
| return new Handlebars.SafeString(str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment