Skip to content

Instantly share code, notes, and snippets.

@MattCheely
Created May 28, 2012 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattCheely/2821130 to your computer and use it in GitHub Desktop.
Save MattCheely/2821130 to your computer and use it in GitHub Desktop.
Bad lambda handling with inheritance example
var prototype = Hogan.compile('<div class="content-one">{{$content1}}{{/content1}}</div>\n<div class="content-two">{{$content2}}{{/content2}}</div>');
var sub = Hogan.compile('{{< prototype}}{{$content1}}{{#i18n}}content{{/i18n}}{{/content1}}{{/ prototype}}');
function translateLambda() {
return function(message) {
console.log(message); //logs '}{{/con'
return 'translated ' + message;
}
}
var rendered = sub.render({i18n: translateLambda}, {prototype: prototype});
console.log(rendered);
/* logs:
<div class="content-one">translated }con</div>
<div class="content-two"></div>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment