photon-mustache 0.1.0
Compile-time mustache template engine for photon-http or standalone
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
photon-mustache
Compile-time mustache templating for photon-http and standalone.
Example
Given template.mustache:
Hello {{name}}
You have just won {{value}} dollars!
{{#in_ca}}
Well, {{taxed_value}} dollars, after taxes.
{{/in_ca}}
The following should render the template to the stdout:
import std.stdio;
import photon.mustache;
struct Context {
string name;
double value;
double taxed_value;
bool in_ca;
}
static templ = mustache!(import("template.mustache"), Context);
void writeTemplate()
{
auto ctx = Context("Chris", 1000, 1000 - 0.4 * 1000, true);
templ(ctx, lockingTextWriter(stdout));
}
API
photon-mustache is aimed for fastest rendering of compile-time known nested data structures, anything that is sliceable is considered a list and anything that supports opIndex with strings is considered a dynamic context and can subsequently be nested.
Internally mustache!(...) template generates a callable template that accepts value and an output range of char.
- 0.1.0 released 2 days ago
- DmitryOlshansky/photon-mustache
- BSL-1.0
- Copyright © 2025, Dmitry Olshansky
- Authors:
- Dependencies:
- none
- Versions:
-
Show all 3 versions0.1.1 2025-Nov-03 0.1.0 2025-Nov-03 ~master 2025-Nov-03 - Download Stats:
-
-
0 downloads today
-
11 downloads this week
-
11 downloads this month
-
11 downloads total
-
- Score:
- 0.2
- Short URL:
- photon-mustache.dub.pm