class Hanami::Helpers::FormHelper::HtmlNode
HTML form node
@since 0.2.0 @api private
Public Class Methods
new(name, content, attributes, options)
click to toggle source
Initialize a new HTML form node
@param name [Symbol,String] the name of the tag @param content [String,Proc,Hanami::Helpers::HtmlHelper::FormBuilder,NilClass] the optional content @param attributes [Hash,NilClass] the optional tag attributes @param options [Hash] a set of data
@return [Hanami::Helpers::FormHelper::HtmlNode]
@since 0.2.0 @api private
Calls superclass method
Hanami::Helpers::HtmlHelper::HtmlNode::new
# File lib/hanami/helpers/form_helper/html_node.rb, line 24 def initialize(name, content, attributes, options) super @verb = options.fetch(:verb, nil) @csrf_token = options.fetch(:csrf_token, nil) @builder = FormBuilder.new( options.fetch(:name), options.fetch(:values) ) end
Private Instance Methods
_csrf_protection!()
click to toggle source
Inject a hidden field for CSRF Protection token
@since 0.2.0 @api private
# File lib/hanami/helpers/form_helper/html_node.rb, line 69 def _csrf_protection! return if @csrf_token.nil? csrf_token = @csrf_token @builder.resolve do input(type: :hidden, name: FormHelper::CSRF_TOKEN, value: csrf_token) end end
_method_override!()
click to toggle source
Inject a hidden field to make Method Override possible
@since 0.2.0 @api private
# File lib/hanami/helpers/form_helper/html_node.rb, line 56 def _method_override! return if @verb.nil? verb = @verb @builder.resolve do input(type: :hidden, name: :_method, value: verb) end end
content()
click to toggle source
Resolve the (nested) content
@return [String] the content
@since 0.2.0 @api private
@see Hanami::Helpers::HtmlHelper::HtmlNode#content
Calls superclass method
Hanami::Helpers::HtmlHelper::HtmlNode#content
# File lib/hanami/helpers/form_helper/html_node.rb, line 46 def content _method_override! _csrf_protection! super end