Module: Lux::Application::Render

Extended by:
Render
Included in:
Render
Defined in:
lib/lux/application/lib/render.rb

Instance Method Summary collapse

Instance Method Details

#cell(name, *args) ⇒ Object

Lux.render.cell(:user, self, { product: @bar }).foo Lux.render.cell(:user, self).foo Lux.render.cell(:user, { product: @bar }).foo Lux.render.cell(:user).foo @arg



41
42
43
44
45
# File 'lib/lux/application/lib/render.rb', line 41

def cell name, *args
  opts    = args.last.is_a?(Hash) ? args.pop : {}
  context = args.shift
  Lux::ViewCell.get(name, context, opts)
end

#controller(klass, &block) ⇒ Object

Render controller action without routes, pass a block to yield before action call. ‘Lux.render.controller(’main/cities#foo’).body` ‘Lux.render.controller(’main/cities#foo’) { @city = City.last_updated }.body`



21
22
23
24
25
26
27
28
29
30
# File 'lib/lux/application/lib/render.rb', line 21

def controller klass, &block
  klass, action = klass.split('#')

  klass = (klass+'Controller').classify.constantize if klass.is_a?(String)
  c = klass.new
  c.instance_exec &block if block
  c.send action

  Lux.current.response
end

#template(*args) ⇒ Object

Lux.render.controller(‘main/cities#bar’) { @city = City.last_updated }.body



33
34
35
# File 'lib/lux/application/lib/render.rb', line 33

def template *args
  Lux::Template.render *args
end