Crossfire Server, Trunk
inja::Renderer Class Reference

Class for rendering a Template with data. More...

#include <inja.hpp>

+ Inheritance diagram for inja::Renderer:
+ Collaboration diagram for inja::Renderer:

Public Member Functions

void render_to (std::ostream &os, const Template &tmpl, const json &data, json *loop_data=nullptr)
 
 Renderer (const RenderConfig &config, const TemplateStorage &template_storage, const FunctionStorage &function_storage)
 
- Public Member Functions inherited from inja::NodeVisitor
virtual ~NodeVisitor ()=default
 

Private Types

using Op = FunctionStorage::Operation
 

Private Member Functions

const std::shared_ptr< jsoneval_expression_list (const ExpressionListNode &expression_list)
 
template<bool throw_not_found = true>
Arguments get_argument_vector (const FunctionNode &node)
 
template<size_t N, size_t N_start = 0, bool throw_not_found = true>
std::array< const json *, N > get_arguments (const FunctionNode &node)
 
void print_json (const std::shared_ptr< json > value)
 
void throw_renderer_error (const std::string &message, const AstNode &node)
 
bool truthy (const json *data) const
 
void visit (const BlockNode &node)
 
void visit (const BlockStatementNode &node)
 
void visit (const ExpressionListNode &node)
 
void visit (const ExpressionNode &)
 
void visit (const ExtendsStatementNode &node)
 
void visit (const ForArrayStatementNode &node)
 
void visit (const ForObjectStatementNode &node)
 
void visit (const ForStatementNode &)
 
void visit (const FunctionNode &node)
 
void visit (const IfStatementNode &node)
 
void visit (const IncludeStatementNode &node)
 
void visit (const JsonNode &node)
 
void visit (const LiteralNode &node)
 
void visit (const SetStatementNode &node)
 
void visit (const StatementNode &)
 
void visit (const TextNode &node)
 

Private Attributes

std::vector< const BlockStatementNode * > block_statement_stack
 
bool break_rendering {false}
 
const RenderConfig config
 
size_t current_level {0}
 
jsoncurrent_loop_data = &json_additional_data["loop"]
 
const Templatecurrent_template
 
const FunctionStoragefunction_storage
 
json json_additional_data
 
std::stack< const json * > json_eval_stack
 
const jsonjson_input
 
std::vector< std::shared_ptr< json > > json_tmp_stack
 
std::stack< const JsonNode * > not_found_stack
 
std::ostream * output_stream
 
std::vector< const Template * > template_stack
 
const TemplateStoragetemplate_storage
 

Detailed Description

Class for rendering a Template with data.

Definition at line 3519 of file inja.hpp.

Member Typedef Documentation

◆ Op

Definition at line 3520 of file inja.hpp.

Constructor & Destructor Documentation

◆ Renderer()

inja::Renderer::Renderer ( const RenderConfig &  config,
const TemplateStorage template_storage,
const FunctionStorage function_storage 
)
inline

Definition at line 4192 of file inja.hpp.

Member Function Documentation

◆ eval_expression_list()

const std::shared_ptr<json> inja::Renderer::eval_expression_list ( const ExpressionListNode expression_list)
inlineprivate

Definition at line 3565 of file inja.hpp.

References rotate-tower::result, and inja::ExpressionListNode::root.

◆ get_argument_vector()

template<bool throw_not_found = true>
Arguments inja::Renderer::get_argument_vector ( const FunctionNode node)
inlineprivate

Definition at line 3631 of file inja.hpp.

References disinfect::a, inja::FunctionNode::arguments, rotate-tower::result, and nonstd::sv_lite::to_string().

+ Here is the call graph for this function:

◆ get_arguments()

template<size_t N, size_t N_start = 0, bool throw_not_found = true>
std::array<const json*, N> inja::Renderer::get_arguments ( const FunctionNode node)
inlineprivate

Definition at line 3600 of file inja.hpp.

References inja::FunctionNode::arguments, rotate-tower::result, and nonstd::sv_lite::to_string().

+ Here is the call graph for this function:

◆ print_json()

void inja::Renderer::print_json ( const std::shared_ptr< json value)
inlineprivate

Definition at line 3554 of file inja.hpp.

◆ render_to()

void inja::Renderer::render_to ( std::ostream &  os,
const Template tmpl,
const json data,
json loop_data = nullptr 
)
inline

Definition at line 4195 of file inja.hpp.

References inja::BlockNode::accept(), navar-midane_time::data, nlohmann::basic_json::emplace_back(), and inja::Template::root.

Referenced by inja::Environment::render_to().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ throw_renderer_error()

void inja::Renderer::throw_renderer_error ( const std::string &  message,
const AstNode node 
)
inlineprivate

Definition at line 3594 of file inja.hpp.

References inja::Template::content, inja::get_source_location(), INJA_THROW, diamondslots::message, and inja::AstNode::pos.

+ Here is the call graph for this function:

◆ truthy()

bool inja::Renderer::truthy ( const json data) const
inlineprivate

Definition at line 3543 of file inja.hpp.

References navar-midane_time::data.

◆ visit() [1/16]

void inja::Renderer::visit ( const BlockNode node)
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 3658 of file inja.hpp.

References inja::BlockNode::nodes.

◆ visit() [2/16]

void inja::Renderer::visit ( const BlockStatementNode node)
inlineprivatevirtual

◆ visit() [3/16]

void inja::Renderer::visit ( const ExpressionListNode node)
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 4054 of file inja.hpp.

◆ visit() [4/16]

void inja::Renderer::visit ( const ExpressionNode )
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 3672 of file inja.hpp.

◆ visit() [5/16]

void inja::Renderer::visit ( const ExtendsStatementNode node)
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 4159 of file inja.hpp.

References inja::ExtendsStatementNode::file, and inja::render_to().

+ Here is the call graph for this function:

◆ visit() [6/16]

void inja::Renderer::visit ( const ForArrayStatementNode node)
inlineprivatevirtual

◆ visit() [7/16]

◆ visit() [8/16]

void inja::Renderer::visit ( const ForStatementNode )
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 4060 of file inja.hpp.

◆ visit() [9/16]

◆ visit() [10/16]

void inja::Renderer::visit ( const IfStatementNode node)
inlineprivatevirtual

◆ visit() [11/16]

void inja::Renderer::visit ( const IncludeStatementNode node)
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 4149 of file inja.hpp.

References inja::IncludeStatementNode::file.

◆ visit() [12/16]

void inja::Renderer::visit ( const JsonNode node)
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 3678 of file inja.hpp.

References nlohmann::basic_json::contains(), inja::FunctionStorage::find_function(), inja::JsonNode::name, and inja::JsonNode::ptr.

+ Here is the call graph for this function:

◆ visit() [13/16]

void inja::Renderer::visit ( const LiteralNode node)
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 3674 of file inja.hpp.

References inja::LiteralNode::value.

◆ visit() [14/16]

void inja::Renderer::visit ( const SetStatementNode node)
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 4184 of file inja.hpp.

References inja::SetStatementNode::expression, inja::SetStatementNode::key, and inja::replace_substring().

+ Here is the call graph for this function:

◆ visit() [15/16]

void inja::Renderer::visit ( const StatementNode )
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 4058 of file inja.hpp.

◆ visit() [16/16]

void inja::Renderer::visit ( const TextNode node)
inlineprivatevirtual

Implements inja::NodeVisitor.

Definition at line 3668 of file inja.hpp.

References inja::Template::content, inja::TextNode::length, and inja::AstNode::pos.

Field Documentation

◆ block_statement_stack

std::vector<const BlockStatementNode*> inja::Renderer::block_statement_stack
private

Definition at line 3529 of file inja.hpp.

◆ break_rendering

bool inja::Renderer::break_rendering {false}
private

Definition at line 3541 of file inja.hpp.

◆ config

const RenderConfig inja::Renderer::config
private

Definition at line 3522 of file inja.hpp.

◆ current_level

size_t inja::Renderer::current_level {0}
private

Definition at line 3527 of file inja.hpp.

◆ current_loop_data

json* inja::Renderer::current_loop_data = &json_additional_data["loop"]
private

Definition at line 3535 of file inja.hpp.

◆ current_template

const Template* inja::Renderer::current_template
private

Definition at line 3526 of file inja.hpp.

◆ function_storage

const FunctionStorage& inja::Renderer::function_storage
private

Definition at line 3524 of file inja.hpp.

◆ json_additional_data

json inja::Renderer::json_additional_data
private

Definition at line 3534 of file inja.hpp.

◆ json_eval_stack

std::stack<const json*> inja::Renderer::json_eval_stack
private

Definition at line 3538 of file inja.hpp.

◆ json_input

const json* inja::Renderer::json_input
private

Definition at line 3531 of file inja.hpp.

◆ json_tmp_stack

std::vector<std::shared_ptr<json> > inja::Renderer::json_tmp_stack
private

Definition at line 3537 of file inja.hpp.

◆ not_found_stack

std::stack<const JsonNode*> inja::Renderer::not_found_stack
private

Definition at line 3539 of file inja.hpp.

◆ output_stream

std::ostream* inja::Renderer::output_stream
private

Definition at line 3532 of file inja.hpp.

◆ template_stack

std::vector<const Template*> inja::Renderer::template_stack
private

Definition at line 3528 of file inja.hpp.

◆ template_storage

const TemplateStorage& inja::Renderer::template_storage
private

Definition at line 3523 of file inja.hpp.


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