Module: DryHamlHandlebars::ViewHelpers::ActionView
- Defined in:
- lib/dry_haml_handlebars/view_helpers/action_view.rb
Instance Method Summary collapse
-
#handlebars_content_for(name, content = nil, flush = false) ⇒ Object
WARNING: content_for is ignored in caches.
- #handlebars_render(*args, &block) ⇒ Object
Instance Method Details
#handlebars_content_for(name, content = nil, flush = false) ⇒ Object
WARNING: content_for is ignored in caches. So you shouldn’t use it for elements that will be fragment cached.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dry_haml_handlebars/view_helpers/action_view.rb', line 7 def (name, content = nil, flush = false) if content flush ? @view_flow.set(name, content) : @view_flow.append(name, content) nil else @view_flow.get(name) end end |
#handlebars_render(*args, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dry_haml_handlebars/view_helpers/action_view.rb', line 18 def (*args, &block) #we simply wrap render so that we can detect that 'handlebars_render' was the calling function #we do this by adding a local variable :handlebars_partial => true if args.first.is_a?(Hash) = args.first [:locals] ||= {} [:locals].merge!(:__handlebars_partial => true) elsif args.last.is_a?(Hash) locals = args.last locals[:__handlebars_partial] = true else args << {:__handlebars_partial => true} end render(*args, &block) end |