<commit_before>/**
 * handlebars.form-helpers.js
 * https://github.com/badsyntax/handlebars-form-helpers
 * Copyright (c) 2013 <NAME>; Licensed MIT
 */

(function (factory) {
  if (typeof exports === 'object') {
    // Node/CommonJS
    exports = module.exports = factory;
  } else if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(function() {
      return factory;
    });
  } else {
    // Browser globals
    factory(Handlebars);
  }
}(function(Handlebars) {

  /* Markup helpers
  *****************************************/

  function openTag(type, closing, attr) {
    var html = ['<' + type];
    for (var prop in attr) {
      // A falsy value is used to remove the attribute.
      // EG: attr[false] to remove, attr['false'] to add
      if (attr[prop]) {
        html.push(prop + '="' + attr[prop] + '"');
      }
    }
    return html.join(' ') + (!closing ? ' /' : '') + '>';
  }

  function closeTag(type) {
    return '</' + type + '>';
  }

  function createElement(type, closing, attr, contents) {
    return openTag(type, closing, attr) + (closing ? (contents || '') + closeTag(type) : '');
  }

  /* Object, array and validation helpers
   *****************************************/

  function extend(obj1, obj2) {
    for (var prop in obj2) {
      if (obj2.hasOwnProperty(prop)) {
        obj1[prop] = obj2[prop];
      }
    }
    return obj1;
  }

  function indexOf(arr, find) {
    for(var i = 0, j = arr.length; i < j; i++) {
      if (arr[i] === find) {
        return i;
      }
    }
    return -1;
  }

  function hasValidationError(value, errors) {
    return !!(errors || {})[value];
  }

  function addValidationClass(value, errors, options) {
    options = options || {};
    if (errors === true || hasValidationError(value, errors)) {
      var hash = options.hash;
      hash['class'] = (hash['class'] ? hash['class'] + ' ' : '') + validationErrorClass;
    }
    return options;
  }

  /* Form element strings
   *****************************************/

  var form = 'form', input = 'input', label = 'label', button = 'button',
    submit = 'submit', select = 'select', option = 'option', checkbox = 'checkbox',
    radio = 'radio', hidden = 'hidden', textarea = 'textarea', password = 'password',
    file = 'file';

  /* Validation strings
   *****************************************/

  var validationErrorClass = 'validation-error', validationSufffix = '_validation',
    field_errors = 'field_errors';

  /* Form helpers
   *****************************************/

  /* {{#form url class="form"}}{{/form}} */
  function helperForm(url, options) {
    return createElement(form, true, extend({
      action: url,
      method: 'POST'
    }, options.hash), options.fn(this));
  }

  /* {{input "firstname" person.name}} */
  function helperInput(name, value, options) {
    return new Handlebars.SafeString(createElement(input, false, extend({
      name: name,
      id: name,
      value: value,
      type: 'text'
    }, options.hash)));
  }

  /* {{input_validation "firstname" person.name errors}} */
  function helperInputValidation(name, value, errors, options) {
    return helperInput(name, value, addValidationClass(name, errors, options));
  }

  /* {{label "name" "Please enter your name"}} */
  /* {{#label}}Anything here{{/label}} */
  function helperLabel(input, body, options) {

    options = Array.prototype.pop.call(arguments);
    body = options.fn && options.fn(input) || body;

    var attr = {};
    if (typeof input === 'string') {
      attr['for'] = input;
    }

    var element = createElement(label, true, extend(attr, options.hash), body)
<commit_msg>Fixed tests<commit_after>/**
 * handlebars.form-helpers.js
 * https://github.com/badsyntax/handlebars-form-helpers
 * Copyright (c) 2013 <NAME>; Licensed MIT
 */

(function (factory) {
  if (typeof exports === 'object') {
    // Node/CommonJS
    exports = module.exports = factory;
  } else if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(function() {
      return factory;
    });
  } else {
    // Browser globals
    factory(Handlebars);
  }
}(function(Handlebars) {

  /* Markup helpers
  *****************************************/

  function openTag(type, closing, attr) {
    var html = ['<' + type];
    for (var prop in attr) {
      // A falsy value is used to remove the attribute.
      // EG: attr[false] to remove, attr['false'] to add
      if (attr[prop]) {
        html.push(prop + '="' + attr[prop] + '"');
      }
    }
    return html.join(' ') + (!closing ? ' /' : '') + '>';
  }

  function closeTag(type) {
    return '</' + type + '>';
  }

  function createElement(type, closing, attr, contents) {
    return openTag(type, closing, attr) + (closing ? (contents || '') + closeTag(type) : '');
  }

  /* Object, array and validation helpers
   *****************************************/

  function extend(obj1, obj2) {
    for (var prop in obj2) {
      if (obj2.hasOwnProperty(prop)) {
        obj1[prop] = obj2[prop];
      }
    }
    return obj1;
  }

  function indexOf(arr, find) {
    for(var i = 0, j = arr.length; i < j; i++) {
      if (arr[i] === find) {
        return i;
      }
    }
    return -1;
  }

  function hasValidationError(value, errors) {
    return !!(errors || {})[value];
  }

  function addValidationClass(value, errors, options) {
    options = options || {};
    if (errors === true || hasValidationError(value, errors)) {
      var hash = options.hash;
      hash['class'] = (hash['class'] ? hash['class'] + ' ' : '') + validationErrorClass;
    }
    return options;
  }

  /* Form element strings
   *****************************************/

  var form = 'form', input = 'input', label = 'label', button = 'button',
    submit = 'submit', select = 'select', option = 'option', checkbox = 'checkbox',
    radio = 'radio', hidden = 'hidden', textarea = 'textarea', password = 'password',
    file = 'file';

  /* Validation strings
   *****************************************/

  var validationErrorClass = 'validation-error', validationSufffix = '_validation',
    field_errors = 'field_errors';

  /* Form helpers
   *****************************************/

  /* {{#form url class="form"}}{{/form}} */
  function helperForm(url, options) {
    return createElement(form, true, extend({
      action: url,
      method: 'POST'
    }, options.hash), options.fn(this));
  }

  /* {{input "firstname" person.name}} */
  function helperInput(name, value, options) {
    return new Handlebars.SafeString(createElement(input, false, extend({
      name: name,
      id: name,
      value: value,
      type: 'text'
    }, options.hash)));
  }

  /* {{input_validation "firstname" person.name errors}} */
  function helperInputValidation(name, value, errors, options) {
    return helperInput(name, value, addValidationClass(name, errors, options));
  }

  /* {{label "name" "Please enter your name"}} */
  /* {{#label}}Anything here{{/label}} */
  function helperLabel(input, body, options) {

    options = Array.prototype.pop.call(arguments);
    body = options.fn && options.fn(input) || body;

    var attr = {};
    if (typeof input === 'string') {
      attr['for'] = input;
    }

    var element = createElement(label, true, extend(attr, options.hash), body);

{'fraction_non_alphanumeric': 0.21503188169854837, 'fraction_numerical': 0.003527336860670194, 'mean_word_length': 3.0461031833150383, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '6588764', 'n_tokens_mistral': 2254, 'n_tokens_neox': 2185, 'n_words': 563}