Module: Ckpages::ApplicationHelper

Defined in:
app/helpers/ckpages/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#ckpart(title, options = {}, locals = {}, &block) ⇒ Object



4
5
6
7
8
# File 'app/helpers/ckpages/application_helper.rb', line 4

def ckpart title, options = {}, locals = {}, &block
  @part = Ckpages::Part.find_by!(title: title)
  options = options.merge(partial: 'ckpart')
  render options, locals, &block
end

#dt_dd(page, attr, lmbd = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/ckpages/application_helper.rb', line 10

def dt_dd(page, attr, lmbd=nil)
  if page.send("#{attr}?")
    (:dt) do
      Page.human_attribute_name(attr)
    end +
    (:dd) do
      val = page.send("#{attr}")
      if lmbd.nil?
        val.to_s
      else
        lmbd.call(val)
      end
    end
  end
end