mstch/test/data/higher_order_sections.hpp

27 lines
925 B
C++
Raw Normal View History

2020-02-13 03:53:14 +08:00
class higher_order_sections : public mstch::object {
private:
std::string m_helper;
2015-04-23 21:55:18 +08:00
2020-02-13 03:53:14 +08:00
public:
higher_order_sections() : m_helper("To tinker?") {
register_methods(this,
std::map<std::string, mstch::node (higher_order_sections::*)()>{
{"name", &higher_order_sections::name},
{"helper", &higher_order_sections::helper},
{"bolder", &higher_order_sections::bolder}});
}
2015-04-23 21:55:18 +08:00
2020-02-13 03:53:14 +08:00
mstch::node name() { return std::string{"Tater"}; }
2015-04-23 21:55:18 +08:00
2020-02-13 03:53:14 +08:00
mstch::node helper() { return m_helper; }
mstch::node bolder() {
return mstch::lambda_wrapper{{[this](const std::string& text) -> mstch::node {
return "<b>" + text + "</b> " + m_helper;
}}};
}
2015-04-23 21:55:18 +08:00
};
2020-02-13 03:53:14 +08:00
const mstch::node higher_order_sections_data =
mstch::object_wrapper{std::make_shared<higher_order_sections>()};