title | layout |
---|---|
Helpers |
default |
Helpers are Ruby modules that get mixed into the template evaluation context. Typically they add methods you may invoke from within templates to produce additional output, retrieve objects or data, or perform other actions.
To add a helper, simply use the helper
keyword in your pipeline
configuration _ext/pipeline.rb
, and specify the module to add as
a helper. Be sure you require
the appropriate files to have
the module loaded.
Awestruct::Extensions::Pipeline.new do
helper Awestruct::Extensions::IntenseDebate
helper Awestruct::Extensions::GoogleAnalytics
end
By default, the _ext/
directory is added to the load path, so you may
simply add your helper definition there.
_ext/my_helper.rb
module MyHelper
def right_now
Time.now
end
end
_ext/pipeline.rb
require 'my_helper'
Awestruct::Extensions::Pipeline.new do
helper MyHelper
end
my_template.html.haml
%h1
Generated \#{right_now}