Readme.md - added Section for customization and notes
[biaweb2.git] / biawebnavigationbit.hpp
1 #ifndef __BIAWEBNAVIGATIONBIT__
2 #define __BIAWEBNAVIGATIONBIT__
3
4 #include <list>
5 #include <fstream>
6 #include <fmt/format.h>
7 #include "biawebutil.hpp"
8 #include "biawebsidebar.hpp"
9 #include "biawebtemplate.hpp"
10
11 namespace biaweb {
12 // class to represent a navigation bit like this in html
13 // > Parent > Child > Subchild
14 // etc.
15 class NavigationBit {
16 protected:
17 std::list<GenericLinkItem> items;
18 public:
19 // add a generic link item - this should add to beginning of the list
20 void add_link_item (GenericLinkItem item) {
21 items.insert (items.cbegin(), item);
22 }
23
24 // render using the given template directory
25 std::string to_html (Template *t) ;
26 };
27
28 // render using the given template
29 std::string NavigationBit::to_html (Template *t) {
30 std::string templ_str = t->get_navigationbit_tpl ();
31
32 std::string output_html = "";
33 std::string items_str = "";
34 for (GenericLinkItem item : this->items)
35 items_str += item.to_html (t);
36
37 if (this->items.size () > 0)
38 output_html = fmt::format (templ_str, fmt::arg ("items", items_str));
39
40 return output_html;
41 }
42 }
43
44 #endif