Module: PolishedKnockout::KnockoutHelpers

Defined in:
lib/polished/knockout/helpers/knockout_helpers.rb

Instance Method Summary collapse

Instance Method Details

#knockout(partial = nil, subview: nil, bind_as: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/polished/knockout/helpers/knockout_helpers.rb', line 3

def knockout(partial=nil, subview:nil, bind_as:nil)
  if partial
    render(partial: 'knockout/' + partial.to_s)
  elsif subview
    subview_with = bind_as || subview.split('/').last
    (:div, 'data-bind' => "with: #{subview_with}") do
      render(partial: 'knockout/' + subview.to_s)
    end
  end
end