Module Nanoc::Helpers::LinkTo
In: lib/nanoc/helpers/link_to.rb

Nanoc::Helpers::LinkTo contains functions for linking to pages.

Methods

Included Modules

Nanoc::Helpers::HTMLEscape

Public Instance methods

Creates a HTML link to the given path or page/asset representation, and with the given text.

path_or_rep:the URL or path (a String) that should be linked to, or the page or asset representation that should be linked to.
text:the visible link text.
attributes:a hash containing HTML attributes that will be added to the link.

Examples:

  link_to('Blog', '/blog/')
  # => '<a href="/blog/">Blog</a>'

  page_rep = @pages.find { |p| p.page_id == 'special' }.reps(:default)
  link_to('Special Page', page_rep)
  # => '<a href="/special_page/">Special Page</a>'

  link_to('Blog', '/blog/', :title => 'My super cool blog')
  # => '<a href="/blog/" title="My super cool blog">Blog</a>

Creates a HTML link using link_to, except when the linked page is the current one. In this case, a span element with class "active" and with the given text will be returned.

Examples:

  link_to('Blog', '/blog/')
  # => '<a href="/blog/">Blog</a>'

  link_to('This Page', @page_rep)
  # => '<span class="active">This Page</span>'

[Validate]