sclass HTMLFramer1 {
S title;
new L navItems;
new LS contents;
new LS headElements;
srecord NavItem(S link, S html) {
bool targetBlank;
}
swappable S render() {
ret hhtml(hhead(htitle(title)
+ lines(headElements))
+ hbody(h1(htmlEncode2(title))
+ renderNav()
+ lines(contents)));
}
swappable S renderNav() {
if (empty(navItems)) ret "";
ret p(joinWithVBar(map(navItems, ni -> ahref_possiblyTargetBlank(ni.link, ni.html, ni.targetBlank))));
}
void addNavItem(S html) {
navItems.add(new NavItem(null, html));
}
void addNavItem(S link, S html, O... _) {
navItems.add(setAll(new NavItem(link, html), filterParams(_, 'targetBlank)));
}
void addInHead(O html) {
headElements.add(str(html));
}
// add contents: TODO move things to head automatically
void add(O html) {
addIfNempty(contents, strOrEmpty(html));
}
}