kainjow/Mustache

Please support template inheritance

Closed this issue · 3 comments

I understand you are targetting v1.1.3 of the mustache spec. However, template inheritance is turning into a defacto standard. It is supported by numerous mustache implementations, javascript, Java and others. For instance, it is supported by 3 of the 4 most popular Java implementations. Its support in javascript implementations mean that it can be used client and server side.

Consider Trimou as a documentation example
http://trimou.org/

^^^^^^^^^^^^

Template inheritance
This useful feature is not supported in the spec. Trimou basically follows the way mustache.java implements the template inheritance.

In the extended template (parent), the sections to extend are defined - use $ to identify such sections.
A section identified with < includes the extended template
In the extending template (child), the extending sections are defined - again, use $ to identify such sections. Sections to extend may define the default content.
The following template with name "super":

{{$header}}
The default header
{{/header}}
In between...
{{$content}}
The default content
{{/content}}
Can be extended in this way:

Hello world!
{{<super}}
{{$header}}
My own header
{{/header}}
Only extending sections are considered...
{{/super}}
Lalala...
And the result is:

Hello world!
My own header
In between...
The default content
Lalala...

Interesting. I'll look into it and see if it can be done. There's a huge thread about it I'll have to dig into.

I have no plans to implement this anymore.

suy commented

FWIW, the other inheritance proposal was merged to the spec, but it's marked as optional.