For information on Haml & Sass please see haml.hamptoncatlin.com.

For the latest version:

gem install staticmatic

or visit:

http://rubyforge.org/projects/staticmatic/

What's it all about?

CMS is overrated. A lot of the time, clients want us to do what we do best - well designed pages with structured, accessible and maintainable markup & styling.

CMSs are often sufficient for this, but sometimes they can be restrictive and more cumbersome than just working with good ol' source code. At the same time we want our code to be structured, DRY and flexible.

Enter StaticMatic.

Usage

StaticMatic will set up a basic site structure for you with this command:

staticmatic setup <directory>

After this command you'll have the following files:

<directory>/
  site/
    images/
    stylesheets/
    javascripts/
  src/
    pages/
      index.haml
    layouts/
      application.haml
    stylesheets/
      application.sass

StaticMatic sets you up with a sample layout, stylesheet and page file. Once you've edited the pages and stylesheets, you can generate the static site:

staticmatic build <directory>

All of the pages are parsed and wrapped up in application.haml and put into the site directory.

Templates

StaticMatic adds a few helpers to the core Haml helpers:

= link 'Title', 'url'
= img 'my_image.jpg'

Coming soon:

I'm already extending these to include some neat conventions to speed up coding. For example, in the next version:

= link 'Contact Us'

will produce

<a href="contact_us.html">Contact Us</a>

Or with the Rewriting enabled:

<a href="contact_us">Contact Us</a>

What's Next?

  • Multiple directories of content
  • Layouts based on directory of page template
  • Additional Helpers
  • Tests, tests, tests!
  • Configuration
  • Default Rewriting for HTML pages (drop the .html)

7 Responses to “StaticMatic - Managing static sites with Haml & Sass”

  1. Paolo Says:

    I really like this idea. I'll try to use your gem for my next static site.

  2. weepy Says:

    Wow - this is exactly something that I built a while ago (minus the haml). Tho' mine was overcomplicated - this looks perfect.

  3. Andy Stewart Says:

    Nice.

    I really like the idea of using Rails at "build-time" to put together a static site. The layouts, for example, are so useful. But when it comes to "run-time" it's just static HTML so Rails is totally unnecessary.

    So I love the way this gives you the best of both worlds by "publishing" a site.

  4. BJ Clark Says:

    1st of all, this looks really cool.

    This may be a really dumb question, since I haven't played with staticmatic much, but is there a way to preview your site without building it every time?

  5. Andrew Says:

    I like this idea a lot. Maybe this adds more complexity than you've intended, but have you thought of adding support for partials or includes? I would also like to see some kind of per-page helper for adding custom ruby code. Thanks!

  6. Stephen Bartholomew Says:

    BJ Clark: There isn't a live preview yet, but it's something I'm working on. Basically, it'll fire up a server and parse the templates live so you can work via a browser.

    I don't consider a preview to be outside the scope of the app as it's all about making things quicker and easier. Having to build each time you need to check a change is not efficient :0)

  7. Daniel B Says:

    Look very cool. But, I can't figure out why I get: $ staticmatic setup static_test /usr/lib/ruby/gems/1.8/gems/staticmatic-0.1.0/bin/../lib/staticmatic.rb:9: undefined method cattr_reader for StaticMatic:Class (NoMethodError)

Sorry, comments are closed for this article.