Environment variables in helpers?

I know I can use environment variables in templates, as described here.

// file.slim
- if development?
    "This is in development"
- if build?
    "This is during build"

…but I can’t get it to work in a helper. Help?

# helpers.rb
def my_helper()
  if development?
    "This is in development"
  end
  if build?
    "This is during build"
  end
end

You can do:

if app.development?
  ...
end

if app.build?
  ...
end

Thanks for the suggestion, @vvasabi. Unfortunately, that results in this error:

undefined local variable or method `app’

Those lines need to be within the helper method. Please see this GH repo for an example.

Figured it out. For anyone needing this, you can do this:

def my_helper()
  if environment == :development
    "This is in development"
  else
    "This is in build"
  end
end

Here’s the line in Middleman source code where this is revealed: https://github.com/middleman/middleman/blob/v3.0.6/middleman-core/lib/middleman-core/application.rb#L202

Sorry, didn’t realize you were on MM3. I should have asked. Glad that you have figured it out.