jamboree / bustache

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

Insert a template into another template? #13

Closed carolinebeltran closed 5 years ago

carolinebeltran commented 5 years ago

Hello and thank you for such a nice library. Is there some way to include (or embed) one template into another template? For example:

{{header}} {{EMBEDDED_TEMPLATE}} {{footer}}

data.emplace("header", "Hello World!"); data.emplace("EMBEDDED_TEMPLATE", "{{header}} - {{footer}}"); data.emplace("footer", "Goodbye World!");

Actual output:

Hello World! {{EMBEDDED_TEMPLATE}} Goodbye World!

Desired output:

Hello World! Hello World! - Goodbye World! Goodbye World!

jamboree commented 5 years ago

I think Partials is what you're looking for, see this example.

carolinebeltran commented 5 years ago

That was it Jamboree, thank you!