Create a gist now

Instantly share code, notes, and snippets.

Embed
My proposal is a declarative syntax for defining replaceable blocks, very much akin to the
way this is done in Django and some other templating systems. Here is simple example:
super.mustache:
<html>
<head><title>{{$title}}Default title{{/title}}</title></head>
<body>
{{>navigation}}
<div class="content">
{{$content}}Default content of the page{{/content}}
</div>
{{>footer}}
</body>
</html>
sub.mustache:
{{<super}}
{{$title}}Profile of {{username}} | Twitter{{/title}}
{{$content}}
Here is {{username}}'s profile page
{{/content}}
{{/super}}```
the virtual mustache template that is rendered:
<html>
<head><title>Profile of {{username}} | Twitter</title></head>
<body>
{{>navigation}}
<div class="content">
Here is {{username}}'s profile page</div>
{{>footer}}
</body>
</html>
There are many ways that people have tried to workaround this limitation including:
- rendering sub templates into {{{content}}} values
- using javascript to render sections separate and splatting them into the DOM
- reproducing the bones in each sub page through a bunch of partials
- creating massive switch statements using sections
All of these allow business logic and code to creep into the template. My proposal
to maintain the declarative nature of mustache by adding this very powerful
inheritance feature.
@devinrhode2

This comment has been minimized.

Show comment
Hide comment
@devinrhode2

devinrhode2 Jul 24, 2012

Props on the proposal, found this from stack overflow.

Props on the proposal, found this from stack overflow.

@spullara

This comment has been minimized.

Show comment
Hide comment
@spullara

spullara Jul 31, 2012

Here is a reference to the proposal on the mustache spec issues list: mustache/spec#38

Owner

spullara commented Jul 31, 2012

Here is a reference to the proposal on the mustache spec issues list: mustache/spec#38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment