Last active
December 20, 2015 19:09
-
-
Save smithcommajoseph/6181253 to your computer and use it in GitHub Desktop.
adding Handlebars helpers in a Rendr app
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
| //the client app.js file | |
| var //... | |
| // register your helpers (my method doesn't return anything, so the assignment is unnecessary) | |
| HandlebarsHelpers = require('../assets/handlebars/helpers').registerHelpers(); | |
| //... |
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
| // ... | |
| rendr_stitch: { | |
| // ... | |
| files: [{ | |
| // ... | |
| src: [ | |
| // ... | |
| // add your handlebars helpers to the src array to be stitched | |
| 'assets/handlebars/*.js' | |
| ] | |
| }] | |
| } | |
| } |
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
| // a file with some helpers, written in the style of the rendr-handlebars/shared/helpers.js file | |
| var rendrHandlbars = require('rendr-handlebars'), | |
| S = require('string'); | |
| function helpers(Handlebars, getTemplate) { | |
| return { | |
| slugify: function(str, block){ | |
| return S(str).slugify().s; | |
| } | |
| }; | |
| } | |
| exports.registerHelpers = function registerHelpers() { | |
| rendrHandlbars.registerHelpers(helpers); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment