1 2 #ifndef MUSTACHE_TEST_FIXTURES_LAMBDAS_HPP 3 #define MUSTACHE_TEST_FIXTURES_LAMBDAS_HPP 4 5 #include "renderer.hpp" 6 #include "lambda.hpp" 7 8 void load_lambdas_into_test_data(mustache::Data * data, std::string name); 9 10 class StaticLambda: public mustache::Lambda { 11 private: 12 std::string tmpl; 13 public: StaticLambda(std::string tmpl)14 StaticLambda(std::string tmpl) { 15 this->tmpl = tmpl; 16 } 17 invoke()18 std::string invoke() { 19 return this->tmpl; 20 } 21 invoke(std::string * text,mustache::Renderer * renderer)22 std::string invoke(std::string * text, mustache::Renderer * renderer) { 23 return this->tmpl; 24 } 25 }; 26 27 class MultipleCallsLambda: public mustache::Lambda { 28 private: 29 int counter; 30 public: MultipleCallsLambda()31 MultipleCallsLambda(): counter(0) {} 32 std::string invoke(); 33 std::string invoke(std::string * text, mustache::Renderer * renderer); 34 }; 35 36 class SectionLambda: public mustache::Lambda { 37 std::string invoke(); 38 std::string invoke(std::string * text, mustache::Renderer * renderer); 39 }; 40 41 class SectionExpansionLambda: public mustache::Lambda { 42 std::string invoke(); 43 std::string invoke(std::string * text, mustache::Renderer * renderer); 44 }; 45 46 class SectionAlternateDelimitersLambda: public mustache::Lambda { 47 std::string invoke(); 48 std::string invoke(std::string * text, mustache::Renderer * renderer); 49 }; 50 51 class SectionMultipleCallsLambda: public mustache::Lambda { 52 public: 53 std::string invoke(); 54 std::string invoke(std::string * text, mustache::Renderer * renderer); 55 }; 56 57 #endif 58