DynamicMatic is a tiny Sinatra extension that integrates Sinatra with StaticMatic. It allows most of your site to be static while having a few dynamic pages that can use the StaticMatic layouts and partials.
Your Sinatra and StaticMatic apps live side-by-side.
site directory is used as the directory for Sinatra's public files,
src directory contains the source for the static pages
and the layouts that are shared between StaticMatic and Sinatra.
Otherwise the standard Sinatra directories are used.
If the Sinatra
:root option is changed,
DynamicMatic will respect that and set the StaticMatic paths appropriately.
If you're using a classic-style Sinatra application,
all you have to do is
If you're using a modular application,
you'll also have to
How it Works
The static pages and stylesheets in the StaticMatic
are served statically - they should be compiled before the server is started.
This can be done using
staticmatic.run("build") in your Sinatra app.
Any dynamic Sinatra pages can make use of the StaticMatic layouts and helpers, but are rendered dynamically on each request.
StaticMatic layouts are made available as normal Sinatra templates.
For example, if you have
application.haml will be used as the
help.haml will be used as the
application.haml will also be used for the default layout for Sinatra pages.
All the StaticMatic helpers, including those for partial-rendering, are available in Sinatra views. The reverse is not true; Sinatra helpers are generally not available for StaticMatic pages, since they are rendered statically.
Sinatra helpers are, however, available for StaticMatic layouts
but only when they're being used for dynamic views.
It's not safe to rely on them being there,
although you can check for their existence with
and call them if they're there.
StaticMatic is configured using
Sinatra is configured using the
In other words, configuration happens as usual.
When you run your app in development mode,
your static pages are actually generated dynamically on each request,
just like with
Once you're in production, though,
they're all served swiftly from the