Class: Locomotive::Steam::Liquid::Tags::RedirectTo

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Concerns::Attributes, Concerns::I18nPage, Concerns::Path
Defined in:
lib/locomotive/steam/liquid/tags/redirect_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

Instance Method Details

#render(context) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/locomotive/steam/liquid/tags/redirect_to.rb', line 12

def render(context)
  if (path = render_path(context)).present?
    # 301 or 302 redirection
    is_permanent = attributes[:permanent].nil? ? true : attributes[:permanent]

    # break the rendering process
    raise Locomotive::Steam::RedirectionException.new(path, permanent: is_permanent)
  end
  ''
end

#wrong_syntax!Object

Raises:

  • (SyntaxError)


23
24
25
# File 'lib/locomotive/steam/liquid/tags/redirect_to.rb', line 23

def wrong_syntax!
  raise SyntaxError.new("Valid syntax: redirect_to <page|page_handle|content_entry|external_url>(, locale: [fr|de|...], with: <page_handle>, permanent: [true|false]")
end