Lux::View - Backend template helpers

Template based rendering helpers

Tempalte render flow

Lux::View - Calling templates

Inline render

= render :_part, name: 'Foo'

in _part.haml access option name: ... via instance variable @_name

Lux::View::Helper

Lux Helpers provide easy way to group common functions.

Example

for this to work

(:rails, @instance_variables_hash).link_to(...)

RailsHelper module has to define link_to method

ViewCell

View components in rails

Define them like this

class CityCell < ViewCell

  before do
    @skill = parent { @skill }
  end

  ###

  def skills
    @city
      .jobs
      .skills[0,3]
      .map{ |it| it[:name].wrap(:span, class: 'skill' ) }
      .join(' ')
  end

  def render city
    @city    = city
    @country = city.country

    template :city
  end
end

And call them on templates like this

cell.city.skills
cell.city.render @city