I'd prefer not to use @@var
or $var
. Extension options are the intended way to do this, but as you've discovered, global helpers are in the global Middleman application's context, not the extension's context.
A good way to do this is to fish the extension out of the global extension registry. So assuming your extension is named :next_previous
:
helpers do
def test_helper
opts = extensions[:next_previous].options
puts opts.defines_setting?(:var1) ? opts.var1 : false
end
end
Note that the options
attribute is actually an instance of ConfigurationManager
, so it's possible to use methods like defines_setting?
to check a setting rather than defined?
.