higher_order_sections.hpp 765 B

12345678910111213141516171819202122232425262728
  1. class higher_order_sections: public mstch::object {
  2. private:
  3. std::string m_helper;
  4. public:
  5. higher_order_sections(): m_helper("To tinker?") {
  6. register_methods(this, std::map<std::string,mstch::node(higher_order_sections::*)()>{
  7. {"name", &higher_order_sections::name},
  8. {"helper", &higher_order_sections::helper},
  9. {"bolder", &higher_order_sections::bolder}
  10. });
  11. }
  12. mstch::node name() {
  13. return std::string{"Tater"};
  14. }
  15. mstch::node helper() {
  16. return m_helper;
  17. }
  18. mstch::node bolder() {
  19. return mstch::lambda{[this](const std::string& text) -> mstch::node {
  20. return "<b>" + text + "</b> " + m_helper;
  21. }};
  22. }
  23. };
  24. const mstch::node higher_order_sections_data = std::make_shared<higher_order_sections>();