Module: HookHelper
- Defined in:
- app/helpers/hook_helper.rb
Instance Method Summary collapse
-
#hook(hook_name, locals = {}, &block) ⇒ Object
Allow hooks to be used in views like this:.
- #locals_hash(names, binding) ⇒ Object
Instance Method Details
#hook(hook_name, locals = {}, &block) ⇒ Object
Allow hooks to be used in views like this:
<%= hook :some_hook %>
<%= hook :some_hook do %>
<p>Some HTML</p>
<% end %>
11 12 13 14 |
# File 'app/helpers/hook_helper.rb', line 11 def hook(hook_name, locals = {}, &block) content = block_given? ? capture(&block) : '' Spree::ThemeSupport::Hook.render_hook(hook_name, content, self, locals) end |
#locals_hash(names, binding) ⇒ Object
16 17 18 |
# File 'app/helpers/hook_helper.rb', line 16 def locals_hash(names, binding) names.inject({}) {|memo, key| memo[key.to_sym] = eval(key, binding); memo} end |