Oh man, I just spend a few hours trying to solve something that would have gone a lot faster if I had known that there was a middleman console!
I was trying to build the next/back logic for going through articles on my blog. There's a chronological thing, but I wanted to also be able to go back and forth on tags. There are a few that are tagged both "ruby" and (say) "rails", and "the next" for both tags was the same I wanted to list it together under both the tags.
The main problem was that I didn't know what sorts of things were available to me in the templates file. When you startup middleman console
it loads up the configuration of your site so then you can start poking around.
$ bundle exec irb
2.0.0-p481 :001 > blog
NameError: undefined local variable or method `blog' for main:Object
from (irb):1
2.0.0-p481 :002 > exit
$ middleman console
== LiveReload is waiting for a browser to connect
2.0.0-p481 :001 > blog
=> #<Middleman::Blog::BlogData: [#<Middleman::Blog::BlogArticle: {"title"=>"Emb
etc.
What middleman console does is load up the middleman environment, and then lets you call methods on the current Middleman::Application
object. If you are using a middleman extension and they've defined helpers, you can get to them here and start poking around.
Handy things:
config
is the middleman config object.
data
is the middleman data object, from the data directory
blog
is the blog config, if you are using middleman-blog
drafts
are the draft articles, if you are using middleman-blog-drafts