Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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:
<head><title>{{$title}}Default title{{/title}}</title></head>
<div class="content">
{{$content}}Default content of the page{{/content}}
{{$title}}Profile of {{username}} | Twitter{{/title}}
Here is {{username}}'s profile page
the virtual mustache template that is rendered:
<head><title>Profile of {{username}} | Twitter</title></head>
<div class="content">
Here is {{username}}'s profile page</div>
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.
Copy link

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