Created
March 31, 2012 03:00
-
-
Save MattCheely/2258867 to your computer and use it in GitHub Desktop.
Hogan.js inheritance failure case
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
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script src="hogan-TEST.js"></script> | |
<script id="parent" type="template/mustache"> | |
This is a parent template.<br/> | |
{{$content}}Child content goes here{{/content}}<br/> | |
Ending the parent template.<br/> | |
</script> | |
<script id="main" type="template/mustache"> | |
Main template start<br/> | |
{{< parent}} | |
{{$content}} | |
This content includes a partial:<br/> {{> include}} | |
{{/content}} | |
{{/ parent}} | |
Main template end | |
</script> | |
<script id="include" type="template/mustache"> | |
INCLUDED CONTENT! | |
</script> | |
<script> | |
$(function () { | |
try { | |
var | |
$target = $('#target'), | |
templates = { | |
parent: Hogan.compile($('#parent').html()), | |
main: Hogan.compile($('#main').html()), | |
include: Hogan.compile($('#include').html()) | |
}; | |
$target.html(templates.main.render({}, templates)); | |
} catch (error) { | |
console.log(error); | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="target"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment