Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/text-template.hpp"
Text template substitution engine.
Can substitute ${placeholders}
by name and can handle conditional and iterated sections. Structural data for the substitution is accessed and navigated through a generic Data Source binding. By default, a binding for Map-of-strings is provided.
Definition at line 339 of file text-template.hpp.
Public Member Functions | |
TextTemplate (string spec) | |
auto | keys () const |
diagnostics: query a list of all active keys expected by the template. More... | |
template<class DAT > | |
string | render (DAT const &data) const |
submit data and materialise rendered results into a single string | |
template<class DAT > | |
auto | submit (DAT const &data) const |
Instantiate this (pre-compiled) TextTemplate using the given data binding. More... | |
Static Public Member Functions | |
template<class DAT > | |
static string | apply (string spec, DAT const &data) |
one-shot shorthand: compile a template and apply it to the given data | |
static ActionSeq | compile (string const &) |
Classes | |
struct | Action |
class | ActionCompiler |
class | InstanceCore |
Iterator »State Core« to process the template instantiation. More... | |
struct | ParseCtx |
Friends | |
class | test::TextTemplate_test |
Private Types | |
using | ActionSeq = std::vector< Action > |
the text template is compiled into a sequence of Actions | |
enum | Clause { IF, FOR } |
enum | Code { TEXT, KEY, COND, JUMP, ITER, LOOP } |
using | Idx = size_t |
cross-references by index number | |
using | ScopeStack = std::stack< ParseCtx, std::vector< ParseCtx > > |
Private Attributes | |
ActionSeq | actions_ |
Additional Inherited Members | |
Private Member Functions inherited from MoveOnly | |
MoveOnly (MoveOnly &&)=default | |
MoveOnly (MoveOnly const &)=delete | |
MoveOnly & | operator= (MoveOnly &&)=delete |
MoveOnly & | operator= (MoveOnly const &)=delete |
struct TextTemplate::ParseCtx |
|
inline |
Instantiate this (pre-compiled) TextTemplate using the given data binding.
std::string_view&
Definition at line 963 of file text-template.hpp.
References lib::explore().
|
inline |
diagnostics: query a list of all active keys expected by the template.
Definition at line 986 of file text-template.hpp.
References lib::explore().
|
inlinestatic |
exposed for testing
Definition at line 615 of file text-template.hpp.