Created
March 3, 2012 18:18
-
-
Save malev/1967225 to your computer and use it in GitHub Desktop.
2nd mustach example
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
var helpers = { | |
truncate: function (str) { | |
if (str.length > 400) { | |
return str.slice(0, 400) + "..."; | |
} else { | |
return str; | |
} | |
} | |
} | |
var template = "<div class='description'>{{#truncate}}{{item.description}}{{/truncate}}</div>"; | |
// items tiene más información | |
items.truncate = function () { | |
return helpers.truncate; | |
}; | |
$("#undiv").html(Mustache.render(template, items); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment