Sha256: 54f8b8cca2ea03742843ab5bedd11d63c158543c1db7ecbd7ea71e18cf3b3c4b

Contents?: true

Size: 956 Bytes

Versions: 13

Compression:

Stored size: 956 Bytes

Contents

module Locomotive
  module Steam
    module Liquid
      module Tags

        class RedirectTo < ::Liquid::Tag

          include Concerns::Attributes
          include Concerns::I18nPage
          include Concerns::Path

          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

          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

        end

        ::Liquid::Template.register_tag('redirect_to'.freeze, RedirectTo)

      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/liquid/tags/redirect_to.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/liquid/tags/redirect_to.rb