Module: Snippr::ViewHelper
- Defined in:
- lib/snippr/view_helper.rb
Instance Method Summary collapse
-
#snippr(*args) ⇒ Object
Returns a snippr specified via
args
. - #snippr_with_path(*args, &block) ⇒ Object
Instance Method Details
#snippr(*args) ⇒ Object
Returns a snippr specified via args
.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/snippr/view_helper.rb', line 17 def snippr(*args) snip = Snip.new *add_view_to_snippr_args(args) content = snip.content.html_safe if block_given? if snip.missing? || snip.blank? concat content elsif content.strip.present? yield content end 0 else extend_snip_content(content, snip) end end |
#snippr_with_path(*args, &block) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/snippr/view_helper.rb', line 33 def snippr_with_path(*args, &block) path = if controller_name == "pages" params[:id].split('/') else [controller_name, params[:action]] end.compact.map { |e| e.to_s.camelize(:lower).to_sym } snippr(*(path + args), &block) end |