Class: Brut::FrontEnd::Components::Inputs::CsrfToken

Inherits:
Brut::FrontEnd::Components::Input show all
Defined in:
lib/brut/front_end/components/inputs/csrf_token.rb

Overview

Renders a hidden field for a form that contains the current CSRF token. You only need to use this directly if you are building a form without FormTag

Instance Method Summary collapse

Methods inherited from Brut::FrontEnd::Component

component_name, #component_name

Methods included from Brut::FrontEnd::Component::Helpers

#global_component, #inline_svg

Methods included from I18n::ForHTML

#html_escape, #t

Methods included from I18n::BaseMethods

#l, #t, #t_direct, #this_field_value

Methods included from Brut::Framework::Errors

#abstract_method!, #bug!

Constructor Details

#initialize(csrf_token:) ⇒ CsrfToken

Returns a new instance of CsrfToken.



4
5
6
# File 'lib/brut/front_end/components/inputs/csrf_token.rb', line 4

def initialize(csrf_token:)
  @csrf_token = csrf_token
end

Instance Method Details

#view_templateObject



7
8
9
# File 'lib/brut/front_end/components/inputs/csrf_token.rb', line 7

def view_template
  input(type: "hidden", name: "authenticity_token", value: @csrf_token)
end