Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please support template inheritance #6

Closed
jwaterloo opened this issue Apr 19, 2017 · 3 comments
Closed

Please support template inheritance #6

jwaterloo opened this issue Apr 19, 2017 · 3 comments

Comments

@jwaterloo
Copy link

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...

@kainjow
Copy link
Owner

kainjow commented Apr 19, 2017

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.

@kainjow
Copy link
Owner

kainjow commented Feb 19, 2018

I have no plans to implement this anymore.

@suy
Copy link

suy commented Aug 4, 2021

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

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

No branches or pull requests

3 participants