The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

56 lines
1001 B

4 weeks ago
  1. cpptempl
  2. =================
  3. This is a template engine for C++.
  4. Copyright
  5. ==================
  6. Author: Ryan Ginstrom
  7. MIT License
  8. Syntax
  9. =================
  10. Variables::
  11. {$variable_name}
  12. Loops::
  13. {% for person in people %}Name: {$person.name}{% endfor %}
  14. If::
  15. {% if person.name == "Bob" %}Full name: Robert{% endif %}
  16. Usage
  17. =======================
  18. Define a template::
  19. string text = "{% if item %}{$item}{% endif %}\n"
  20. "{% if thing %}{$thing}{% endif %}" ;
  21. Set up data::
  22. cpptempl::data_map data ;
  23. data["item"] = "aaa" ;
  24. data["thing"] = "bbb" ;
  25. Parse the template and data::
  26. string result = cpptempl::parse(text, data) ;
  27. Lists, nested maps
  28. ========================
  29. Example::
  30. cpptempl::data_map person_data ;
  31. person_data["name"] = "Bob" ;
  32. person_data["occupation"] = "Plumber" ;
  33. cpptempl::data_map content ;
  34. content["person"] = person_data ;
  35. content["friends"].push_back("Alice") ;
  36. content["friends"].push_back("Bob") ;