MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / ExpressionNode

Class ExpressionNode

src/include/minja/minja.hpp:917–932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

915};
916
917class ExpressionNode : public TemplateNode {
918 std::shared_ptr<Expression> expr;
919public:
920 ExpressionNode(const Location & loc, std::shared_ptr<Expression> && e) : TemplateNode(loc), expr(std::move(e)) {}
921 void do_render(std::ostringstream & out, const std::shared_ptr<Context> & context) const override {
922 if (!expr) throw std::runtime_error("ExpressionNode.expr is null");
923 auto result = expr->evaluate(context);
924 if (result.is_string()) {
925 out << result.get<std::string>();
926 } else if (result.is_boolean()) {
927 out << (result.get<bool>() ? "True" : "False");
928 } else if (!result.is_null()) {
929 out << result.dump();
930 }
931 }
932};
933
934class IfNode : public TemplateNode {
935 std::vector<std::pair<std::shared_ptr<Expression>, std::shared_ptr<TemplateNode>>> cascade;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected