Last active
November 5, 2016 18:02
-
-
Save dhollenbeck/c4cde67aee08a3db06edf34c02ddd543 to your computer and use it in GitHub Desktop.
Handlebars Each New Line (nl2br)
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
// does not support named parameters | |
exports.eachNewLine = function (str, options) { | |
var accum = ''; | |
var data = Handlebars.createFrame(options, options.hash); | |
var arr = str.split(/\r?\n/); | |
arr.map(function(str) { | |
if (str) accum += options.fn(str.trim(), {data: data}); | |
}); | |
return accum; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment