Created
May 28, 2012 20:42
-
-
Save MattCheely/2821130 to your computer and use it in GitHub Desktop.
Bad lambda handling with inheritance 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 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