Themes and the mock_builder
March 2nd, 2007 — 3:29 pm —One of the first big decisions we made with slate was to avoid using a custom templating language for site themes. When the project first started in PHP, I evaluated a number of templating systems such as Smarty, but we came to the conclusion that it simply wasn’t necessary. Aside from the potential overhead, it just wasn’t worth learning another language. Since we would have to teach our designer to write some code, it might as well be the native language of the system.
Fast forward to the rebuild of the system in Ruby on Rails. Templates were a bit messy early on, as I had essentially ported them from PHP to Ruby. However, after rewriting the page building module (named Pagebuilder, actually), and adding in a number of helpers, the templates became very easy to develop and maintain. They became even easier when I literally dropped two tables from the PHP implementation. These tables stored information about the available templates for a theme, and information about what areas of the template were editable. Removing these tables simplified the whole process so much that I wanted to kick myself for not thinking of it sooner.
With the addition of the helpers and the removal of those pesky tables, we won big time. We won because we took out the configuration step completely for themes, which meant that adding a new editable area to a template was as simple as adding a single helper call. We also won because now we can switch a site’s theme without worrying about database mappings.
One small problem
There was, however, one small problem with our solution: our designer needed a way to test these themes on his computer, and it would be overkill to have the entire project on his machine. Plus, it would add unnecessary configuration into the mix again, having to set up the machine to run slate.
Mock builder
My solution was to build an extremely dumbed down version of slate (like, two Ruby files) that would mimic the helpers used in templates. I named the system mock_builder. Here’s a basic run-down of the features/implementation:
- WEBrick server with a custom ERBHandler
- mocks of all necessary helper methods used by templates
- dummy content generator (using Lorem Ipsum)
- user-defined content and navigation via
mock_data.yml - style guide support (to ensure we style things like visited links, tables, etc.)
- user-friendly exception handling
- easy navigation of templates within a theme
- works “out-of-the-box” (uses only Ruby core and standard library)
Mock builder has greatly simplified the process of developing themes for slate. But beyond that, it’s just cool ;-)
About slate
slate is a content management system (CMS) developed using Ruby on Rails focused on rapid production of traditional websites created by WVU Web Services. Read more about why we created slate and a longer list of features of slate. You can also check out a list of sites using slate. If you have questions or comments let us know but if it's a question about open sourcing slate have a look at this article first.Archives
Recent articles
- No Wonder Rails Is Default in Mac OS X Server...
- Good News: An Open Sourced slate Is Coming
- The WVU Open Source License
- Implementation idea: .do templates
- Keeping slate Humming - Part 1
- Campfire for Design & Keeping Your Tag Cloud Running
- Custom configuration settings made easy
- HOW-TO: Add a Gallery to Your Site
- JSONRequest.post Example
- Miscellaneous
Articles
Chris - That's really, really awesome. I still don't completely follow how you did it, but you're right, it is _very_ cool. Oh, and not to be one of those needy readers, but is there a shot at RSS for the comments?
Actually, the next version of slate (0.3.2) has RSS comment feeds. We should be launching it around March 16th.
Nice idea. How about some code samples? :)
Add comment
You are adding a new comment