1 #ifndef __BIAWEBNAVIGATIONBIT__
2 #define __BIAWEBNAVIGATIONBIT__
6 #include <fmt/format.h>
7 #include "biawebutil.hpp"
8 #include "biawebsidebar.hpp"
11 // class to represent a navigation bit like this in html
12 // > Parent > Child > Subchild
16 std::list<GenericLinkItem> items;
18 // add a generic link item - this should add to beginning of the list
19 void add_link_item (GenericLinkItem item) {
20 items.insert (items.cbegin(), item);
23 // render using the given template directory
24 std::string to_html (std::string templatedir) ;
27 // render using the given template
28 std::string NavigationBit::to_html (std::string templatedir) {
29 std::ifstream templ (templatedir + "/navigationbit.tpl.html");
30 std::string templ_str ((std::istreambuf_iterator<char> (templ)),
31 (std::istreambuf_iterator<char> ()));
34 std::string output_html = "";
35 std::string items_str = "";
36 for (GenericLinkItem item : this->items)
37 items_str += item.to_html (templatedir);
39 if (this->items.size () > 0)
40 output_html = fmt::format (templ_str, fmt::arg ("items", items_str));