Class: Proscenium::LinkToComponentArguments

Inherits:
Object
  • Object
show all
Defined in:
lib/proscenium/link_to_helper.rb

Overview

Component handling for the `link_to` helper.

Instance Method Summary collapse

Constructor Details

#initialize(options, name_argument_index, context) ⇒ LinkToComponentArguments

Returns a new instance of LinkToComponentArguments.



26
27
28
29
30
31
32
33
34
# File 'lib/proscenium/link_to_helper.rb', line 26

def initialize(options, name_argument_index, context)
  @options = options
  @name_argument_index = name_argument_index
  @component = @options[@name_argument_index]

  # We have to render the component, and then extract the props from the component. Rendering
  # first ensures that we have all the correct props.
  context.render @component
end

Instance Method Details

#helper_optionsObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/proscenium/link_to_helper.rb', line 36

def helper_options
  @options[@name_argument_index] = "/components#{@component.virtual_path}"
  @options[@name_argument_index += 1] ||= {}
  @options[@name_argument_index][:rel] = 'nofollow'
  @options[@name_argument_index][:data] ||= {}
  @options[@name_argument_index][:data][:component] = {
    path: @component.virtual_path,
    props: @component.props
  }

  @options
end