Inja  3.3.0
A Template Engine for Modern C++
Public Member Functions | List of all members
inja::Environment Class Reference

Class for changing the configuration. More...

#include <environment.hpp>

Public Member Functions

 Environment (const std::string &global_path)
 
 Environment (const std::string &input_path, const std::string &output_path)
 
void set_statement (const std::string &open, const std::string &close)
 Sets the opener and closer for template statements.
 
void set_line_statement (const std::string &open)
 Sets the opener for template line statements.
 
void set_expression (const std::string &open, const std::string &close)
 Sets the opener and closer for template expressions.
 
void set_comment (const std::string &open, const std::string &close)
 Sets the opener and closer for template comments.
 
void set_trim_blocks (bool trim_blocks)
 Sets whether to remove the first newline after a block.
 
void set_lstrip_blocks (bool lstrip_blocks)
 Sets whether to strip the spaces and tabs from the start of a line to a block.
 
void set_search_included_templates_in_files (bool search_in_files)
 Sets the element notation syntax.
 
void set_throw_at_missing_includes (bool will_throw)
 Sets whether a missing include will throw an error.
 
Template parse (nonstd::string_view input)
 
Template parse_template (const std::string &filename)
 
Template parse_file (const std::string &filename)
 
std::string render (nonstd::string_view input, const json &data)
 
std::string render (const Template &tmpl, const json &data)
 
std::string render_file (const std::string &filename, const json &data)
 
std::string render_file_with_json_file (const std::string &filename, const std::string &filename_data)
 
void write (const std::string &filename, const json &data, const std::string &filename_out)
 
void write (const Template &temp, const json &data, const std::string &filename_out)
 
void write_with_json_file (const std::string &filename, const std::string &filename_data, const std::string &filename_out)
 
void write_with_json_file (const Template &temp, const std::string &filename_data, const std::string &filename_out)
 
std::ostream & render_to (std::ostream &os, const Template &tmpl, const json &data)
 
std::string load_file (const std::string &filename)
 
json load_json (const std::string &filename)
 
void add_callback (const std::string &name, const CallbackFunction &callback)
 Adds a variadic callback.
 
void add_void_callback (const std::string &name, const VoidCallbackFunction &callback)
 Adds a variadic void callback.
 
void add_callback (const std::string &name, int num_args, const CallbackFunction &callback)
 Adds a callback with given number or arguments.
 
void add_void_callback (const std::string &name, int num_args, const VoidCallbackFunction &callback)
 Adds a void callback with given number or arguments.
 
void include_template (const std::string &name, const Template &tmpl)
 
void set_include_callback (const std::function< Template(const std::string &, const std::string &)> &callback)
 Sets a function that is called when an included file is not found.
 

Detailed Description

Class for changing the configuration.

Member Function Documentation

◆ include_template()

void inja::Environment::include_template ( const std::string &  name,
const Template tmpl 
)
inline

Includes a template with a given name into the environment. Then, a template can be rendered in another template using the include "<name>" syntax.


The documentation for this class was generated from the following file: