<commit_before>require "./view_helpers"

module Amatista
  module ViewTag
    include ViewHelpers
    
    def text_field(object_name, method, raw_options = [] of Hash(Symbol, String))
      options = options_transfomed(raw_options)
      str_result = StringIO.new
      str_result << "<input type=\"text\" id=\"#{object_name}_#{method}\" name=\"#{object_name}[#{method}]\""
      str_result << " #{options}" unless options.empty?
      str_result << " />"
      str_result.to_s
    end

    def submit_tag(value = "Save", raw_options = [] of Hash(Symbol, String))
      options = options_transfomed(raw_options)
      str_result = StringIO.new
      str_result << "<input name=\"commit\" type=\"submit\" value=\"#{HTML.escape(value)}\""
      str_result << " #{options}" unless options.empty?
      str_result << " />"
      str_result.to_s
    end

    def form_tag(url, method = "post", raw_options = [] of Hash(Symbol, String))
      options = options_transfomed(raw_options)
      str_result = StringIO.new
      str_result << "<form action=\"#{url}\" method=\"#{method}\""
      str_result << " #{options}" unless options.empty?
      str_result << ">"
      str_body_result = StringIO.new
      str_result << yield(str_body_result)
      str_result << "</form>"
      str_result.to_s
    end

  end
end<commit_msg>add HTML.escape to text_field tag<commit_after>require "./view_helpers"

module Amatista
  module ViewTag
    include ViewHelpers
    
    def text_field(object_name, method, raw_options = [] of Hash(Symbol, String))
      options = options_transfomed(raw_options)
      str_result = StringIO.new
      str_result << "<input type=\"text\" id=\"#{HTML.escape(object_name.to_s)}_#{HTML.escape(method.to_s)}\" "
      str_result << "name=\"#{HTML.escape(object_name.to_s)}[#{HTML.escape(method.to_s)}]\""
      str_result << " #{options}" unless options.empty?
      str_result << " />"
      str_result.to_s
    end

    def submit_tag(value = "Save", raw_options = [] of Hash(Symbol, String))
      options = options_transfomed(raw_options)
      str_result = StringIO.new
      str_result << "<input name=\"commit\" type=\"submit\" value=\"#{HTML.escape(value)}\""
      str_result << " #{options}" unless options.empty?
      str_result << " />"
      str_result.to_s
    end

    def form_tag(url, method = "post", raw_options = [] of Hash(Symbol, String))
      options = options_transfomed(raw_options)
      str_result = StringIO.new
      str_result << "<form action=\"#{HTML.escape(url)}\" method=\"#{HTML.escape(method)}\""
      str_result << " #{options}" unless options.empty?
      str_result << ">"
      str_body_result = StringIO.new
      str_result << yield(str_body_result)
      str_result << "</form>"
      str_result.to_s
    end

  end
end
{'fraction_non_alphanumeric': 0.15199425080848006, 'fraction_numerical': 0.0, 'mean_word_length': 3.2245827010622157, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6061356', 'n_tokens_mistral': 879, 'n_tokens_neox': 889, 'n_words': 174}