Sha256: c09e03bed41c0f1b03db56db2e696ad879d6dce36ea5625281540c6aa9e63e52

Contents?: true

Size: 1.11 KB

Versions: 24

Compression:

Stored size: 1.11 KB

Contents

require 'volt/page/bindings/template_binding'

# Component bindings are the same as template bindings, but handle components
# and do not pass their context through
class ComponentBinding < TemplateBinding
  # The context for a component binding can be either the controller, or the 
  # component arguments (@model), with the $page as the context.  This gives
  # components access to the page collections.
  def render_template(full_path, controller_name)
    # TODO: at the moment a :body section and a :title will both initialize different
    # controllers.  Maybe we should have a way to tie them together?
    controller = get_controller(controller_name)
    if controller
      # The user provided a controller, pass in the model as an argument (in a 
      # sub-context)
      args = []
      args << SubContext.new(@model) if @model
      
      current_context = controller.new(*args)
    else
      # The user didn't specify a model, create a 
      current_context = SubContext.new(@model || {}, $page)
    end

    @current_template = TemplateRenderer.new(@target, current_context, @binding_name, full_path)    
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
volt-0.5.9 lib/volt/page/bindings/component_binding.rb
volt-0.5.8 lib/volt/page/bindings/component_binding.rb
volt-0.5.7 lib/volt/page/bindings/component_binding.rb
volt-0.5.6 lib/volt/page/bindings/component_binding.rb
volt-0.5.4 lib/volt/page/bindings/component_binding.rb
volt-0.5.3 lib/volt/page/bindings/component_binding.rb
volt-0.5.2 lib/volt/page/bindings/component_binding.rb
volt-0.5.1 lib/volt/page/bindings/component_binding.rb
volt-0.5.0 lib/volt/page/bindings/component_binding.rb
volt-0.4.18 lib/volt/page/bindings/component_binding.rb
volt-0.4.17 lib/volt/page/bindings/component_binding.rb
volt-0.4.15 lib/volt/page/bindings/component_binding.rb
volt-0.4.14 lib/volt/page/bindings/component_binding.rb
volt-0.4.12 lib/volt/page/bindings/component_binding.rb
volt-0.4.11 lib/volt/page/bindings/component_binding.rb
volt-0.4.10 lib/volt/page/bindings/component_binding.rb
volt-0.4.9 lib/volt/page/bindings/component_binding.rb
volt-0.4.8 lib/volt/page/bindings/component_binding.rb
volt-0.4.7 lib/volt/page/bindings/component_binding.rb
volt-0.4.5 lib/volt/page/bindings/component_binding.rb