|
Boost : |
From: Richard Hodges (hodges.r_at_[hidden])
Date: 2022-12-30 06:13:04
Utility is everything.
Endorsed.
On Fri, 30 Dec 2022 at 01:23, Peter Dimov via Boost <boost_at_[hidden]>
wrote:
> I'm looking for endorsements and a review manager volunteer for
> a new library, Boost.Mustache. It's an implementation of Mustache
> templates (http://mustache.github.io/) in C++11 and at the moment
> supports the mandatory portions of the Mustache spec
> (https://github.com/mustache/spec).
>
> The repository is https://github.com/pdimov/mustache.
>
> Mustache is a simple templating language in which tags of the form
> {{something}} are replaced with the value of the entity `something`, which
> typically means with the member "something" of the JSON object passed
> when rendering the template.
>
> Boost.Mustache can take a Boost.JSON object as the context against which
> data references are resolved, but it can also take arbitrary values that
> can
> be converted to boost::json::value by using boost::json::value_from.
>
> This allows, for instance, described classes (structs and classes annotated
> with Boost.Describe) to be passed as the data context, such that references
> to e.g. {{title}} in the template are resolved to the corresponding `title`
> member of the class.
>
> A simple usage example demonstrating the above is:
>
> ```
> #include <boost/mustache.hpp>
> #include <boost/describe.hpp>
> #include <iostream>
>
> struct item
> {
> std::string title;
> std::string author;
> std::string link;
> };
>
> BOOST_DESCRIBE_STRUCT(item, (), (title, author, link))
>
> struct reference
> {
> std::string heading;
> std::vector<item> items;
> };
>
> BOOST_DESCRIBE_STRUCT(reference, (), (heading, items))
>
> int main()
> {
> reference ref =
> {
> "Reference",
> {
> {
> "Better Bit Mixing - Improving on MurmurHash3's 64-bit
> Finalizer",
> "David Stafford",
> "
> https://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html"
> },
> {
> "Stronger, better, morer, Moremur; a better Murmur3-type
> mixer",
> "Pelle Evensen",
> "
> https://mostlymangling.blogspot.com/2019/12/stronger-better-morer-moremur-better.html
> "
> },
> {
> "Improved mx3 and the RRC test",
> "Jon Maiga",
> "http://jonkagstrom.com/mx3/mx3_rev2.html"
> }
> }
> };
>
> std::string tmpl =
> R"(<html>
> <body>
> <h1>{{heading}}</h1>
> <ul>
> {{#items}}
> <li>
> <strong>{{title}}</strong><br>
> <em>{{author}}</em><br>
> {{link}}
> {{/items}}
> </ul>
> </body>
> </html>)";
>
> boost::mustache::render( tmpl, std::cout, ref, {} );
> }
> ```
>
> The resulting output is
>
> <html>
> <body>
> <h1>Reference</h1>
> <ul>
> <li>
> <strong>Better Bit Mixing - Improving on MurmurHash3's 64-bit
> Finalizer</strong><br>
> <em>David Stafford</em><br>
> <a href="
> https://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html">
> https://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html
> </a>
> <li>
> <strong>Stronger, better, morer, Moremur; a better Murmur3-type
> mixer</strong><br>
> <em>Pelle Evensen</em><br>
> <a href="
> https://mostlymangling.blogspot.com/2019/12/stronger-better-morer-moremur-better.html
> ">
> https://mostlymangling.blogspot.com/2019/12/stronger-better-morer-moremur-better.html
> </a>
> <li>
> <strong>Improved mx3 and the RRC test</strong><br>
> <em>Jon Maiga</em><br>
> <a href="http://jonkagstrom.com/mx3/mx3_rev2.html">
> http://jonkagstrom.com/mx3/mx3_rev2.html>
> </ul>
> </body>
> </html>
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk