Skip to content

Instantly share code, notes, and snippets.

@mattdeclaire
Last active December 19, 2015 22:58
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 mattdeclaire/6030975 to your computer and use it in GitHub Desktop.
Save mattdeclaire/6030975 to your computer and use it in GitHub Desktop.
Examples of Mustache template inheritance. Includes content overrides (sub-page), and content concatenation (alt-page).
<html>
<head>
<title>Alt Page | My Site</title>
</head>
<body>
<p>Hello Alt Page.</p>
<p>Some extra stuff.</p>
</body>
</html>
{{<layout}}
{{$title}}Alt Page{{/title}}
{{$content}}
<p>Hello Alt Page.</p>
{{$content}}
{{$title}} | My Site{{/title}}
{{$content}}
<p>Some extra stuff.</p>
{{/content}}
{{/layout}}
<html>
<head>
<title>My Site</title>
</head>
<body>
<p>Hello World.</p>
</body>
</html>
<html>
<head>
<title>{{$title}}My Site{{/title}}</title>
</head>
<body>
{{$content}}
<p>Hello World.</p>
{{/content}}
</body>
</html>
<html>
<head>
<title>Page</title>
</head>
<body>
<p>Hello Page.</p>
</body>
</html>
{{<layout}}
{{$title}}Page{{/title}}
{{$content}}
<p>Hello Page.</p>
{{/content}}
{{/layout}}
<html>
<head>
<title>Sub Page</title>
</head>
<body>
<p>Hello Sub Page.</p>
</body>
</html>
{{<page}}
{{$title}}Sub Page{{/title}}
{{$content}}
<p>Hello Sub Page.</p>
{{/content}}
{{/page}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment