Class: Locomotive::Steam::Liquid::Tags::LinkTo

Inherits:
Hybrid
  • Object
show all
Includes:
Concerns::Attributes, Concerns::I18nPage, Concerns::Path
Defined in:
lib/locomotive/steam/liquid/tags/link_to.rb

Constant Summary

Constants included from Concerns::Path

Concerns::Path::Syntax

Instance Attribute Summary

Attributes included from Concerns::Path

#handle

Attributes included from Concerns::Attributes

#attributes, #raw_attributes

Instance Method Summary collapse

Methods included from Concerns::Path

#initialize, #render_path

Methods included from Concerns::I18nPage

#change_page_locale

Methods inherited from Hybrid

#find_block_delimiter?, #nodelist, #parse, #render_as_block?

Instance Method Details

#render(context) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/locomotive/steam/liquid/tags/link_to.rb', line 11

def render(context)
  render_path(context) do |page, path|
    label = label_from_page(page)

    if render_as_block?
      context.stack do
        context.scopes.last['target'] = page
        label = super.html_safe
      end
    end

    tag_href  = %(href="#{path}")
    tag_class = %( class="#{css}") if css.present?

    %{<a #{tag_href}#{tag_class}>#{label}</a>}
  end
end

#wrong_syntax!Object

Raises:

  • (SyntaxError)


29
30
31
# File 'lib/locomotive/steam/liquid/tags/link_to.rb', line 29

def wrong_syntax!
  raise SyntaxError.new("Syntax Error in 'link_to' - Valid syntax: link_to page_handle, locale es (locale is optional)")
end