The Middleman build environment
Rails has long had the concept of environments built-in. That is, the ability to set the environment to development, production or test, and only run code when in one or more of those environments. For example, the development environment has class caching turned off by default, so that code is reloaded on every request, perfect whilst developing. In production, this is turned on, for much improved performance.
Middleman has a similar idea, but the environments are build and development.
I recently took advantage of this feature, specifically, the build environment.
The build environment is set when the site is being built using
build. I used this to only include Google Analytics tracking code when the
site is built. This stops local web browsing from affecting my web statistics.
layout.erb, I've used the
build? helper to conditionally include the
As you can see, this is very simple, but also very useful for customising templates at build time.