Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2023-02-07 23:50:09


Andrzej Krzemienski wrote:
> Some further notes on the documentation
>
> https://pdimov.github.io/mustache/doc/html/mustache.html#overview_desc
> ription
> "At the moment it doesn’t implement any of the extensions.".
>
> This seems to imply that in the future the plan is to support the extensions. The
> only extension that I am aware of is lambdas. But I do not see how lambdas
> can be implemented in the library if it is using boost::json for providing data.

I intend to implement the dynamic names extension:

https://github.com/mustache/spec/blob/master/specs/~dynamic-names.yml

It's simple, but very useful.

> Next, in the same section we have:
>
> Converts partials to boost::json::object by boost::json::value_from(partials,
> sp).as_object() and stores it.
>
> It is far from obvious to me why the 'partials' should be converted to a
> json::value.

That's to allow C++ types to be passed in, such as std::map<std::string,
std::string>.

> Conceptually, you should only require a map of names onto texts.
> But json::value allows too much. According to the specs, the following should
> is valid:
>
> boost::mustache::render( html, std::cout, ref,
> { {"header", header}, {"footer", 1}, {"item", true}, {"body", nullptr} } );
>
> But it shouldn't be valid. Or amI wrong?

The specification doesn't really say what happens when the partial isn't a string.
I haven't checked what other implementations do in this case.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk