Search code examples
middlemanmiddleman-4

How can helpers be accessed from Middleman Console


How can helpers be accessed from middleman console? Answer for both 3.x and 4.x would be helpful if it's not the same object path.


Solution

  • I couldn't find any documentation on this, so settled for the following work around:

    Here's my helper

    module PageHelpers
      def thing
        "THING!"
      end
    end
    

    Call the helper method on an instance of a class that includes it:

    $ bundle exec middleman console
    irb...> (class Thing; include PageHelpers; end).new.thing
    => "THING!"