Skip to content

Instantly share code, notes, and snippets.

@MattCheely
Created March 31, 2012 03:00
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/2258867 to your computer and use it in GitHub Desktop.
Save MattCheely/2258867 to your computer and use it in GitHub Desktop.
Hogan.js inheritance failure case
<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