I'm using Moovweb/Tritium to make a regular desktop site responsive using the Zurb Foundation framework.
As part of this I'd like to create helper functions for enabling Foundation widgets like the the Uranium integrations already in Moovweb. But some of the Foundation components, like the top bar have complex layouts that require more configuration than seems reasonable in a single function call.
For example, enabling the top bar requires something like the following structure:
# Use the foundation topbar
insert_top("nav", class: "top-bar") {
# Create the title area
insert("ul", class: "title-area") {
inject("<li class='name'><h1><a href='/'>Website Name</a></h1></li>")
inject("<li class='toggle-topbar menu-icon'><a href='#'><span>Menu</span></a></li>")
}
# Grab the header links and put them in the top bar
insert("section", class: "top-bar-section") {
insert("ul", class: "left") {
# Move the original header links here
move_here("//span[@class='pagetop']//a"){
wrap("li")
}
}
}
}
What's the right way to abstract this into reusable tritium functions that minimize boilerplate yet allow for flexibility?