module Tablets::ViewHelpers

View helpers included to Rails

Public Instance Methods

render_tablet(name, opts = {}) click to toggle source

Finds tablet by name and renders is with params in current view context

<%= render_tablet :posts, user_id: @user.id %>

initialize_instantly option skips waiting for page:change event and initializes tablet instantly
# File lib/tablets/view_helpers.rb, line 11
def render_tablet(name, opts = {})
  locals = opts.fetch(:locals, {})
  initialize_instantly = opts.fetch(:initialize_instantly, false)

  Tablets::Renderer.new(Tablets[name.to_s].new, locals, initialize_instantly: initialize_instantly).render(self)
end