jamboree / bustache

C++20 implementation of {{ mustache }}
82 stars 10 forks source link

Please support template inheritance #1

Closed jwaterloo closed 7 years ago

jwaterloo commented 7 years ago

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

jamboree commented 7 years ago

It's actually supported, see demo. I should document it though.