Sha256: 5756c08f5617a92601538563c280097853e079b6651f4b4ed2386ddf7408f32c

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module Locomotive
  module Liquid
    module Tags
      module Csrf

        class Param < ::Liquid::Tag

          def render(context)
            controller  = context.registers[:controller]
            name        = controller.send(:request_forgery_protection_token).to_s
            value       = controller.send(:form_authenticity_token)

            %(<input type="hidden" name="#{name}" value="#{value}" />)
          end

        end

        class Meta < ::Liquid::Tag

          def render(context)
            controller  = context.registers[:controller]
            name        = controller.send(:request_forgery_protection_token).to_s
            value       = controller.send(:form_authenticity_token)

            %{
              <meta name="csrf-param" content="#{name}" />
              <meta name="csrf-token" content="#{value}" />
            }
          end

        end

      end

      ::Liquid::Template.register_tag('csrf_param', Csrf::Param)
      ::Liquid::Template.register_tag('csrf_meta', Csrf::Meta)

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc12 lib/locomotive/liquid/tags/csrf.rb
locomotive_cms-2.0.0.rc11 lib/locomotive/liquid/tags/csrf.rb
locomotive_cms-2.0.0.rc10 lib/locomotive/liquid/tags/csrf.rb
locomotive_cms-2.0.0.rc9 lib/locomotive/liquid/tags/csrf.rb
locomotive_cms-2.0.0.rc8 lib/locomotive/liquid/tags/csrf.rb