<commit_before>var Template;

Template = (function(element) {
    var prototype;
    var constructor;

    constructor = Template;
    prototype = Template.prototype;

    constructor.className = "Template";

    prototype.setElement = function(element) {
        element = element.content.firstElementChild;

        this.element = element;

        return element;
    };

    prototype.prepare = function(data) {
        var element, html, mods;

        element = this.element.cloneNode(true);

        html = element.innerHTML;

        mods = {
            time: {
                iso: function() {
                    return (new Date()).toISOString();
                }
            }
        };

        html = html.replace(/\{([^}]+)\}/g, function() {
            var original, capture;

            original = arguments[0];
            capture = arguments[1];

            if (capture.indexOf(":") !== -1) {
                    var mod, func;

                    mod = capture.split(":");
                    func = mod.pop();
                    mod = mod.shift();

                    if (mods[mod] && mods[mod][func]) {
                        return mods[mod][func](capture);
                    }
            } else if (data.hasOwnProperty(capture)) {
                return data[capture];

            }
            return original;
        });

        element.innerHTML = html;

        return element;
    };

    function Template(element) {
        this.setElement(element);
    }

    return Template;
}());

module.exports = Template;<commit_msg>Deap property and self-resolving element queries<commit_after>var Template;

Template = (function(element) {
    var prototype;
    var constructor;

    constructor = Template;
    prototype = Template.prototype;

    constructor.className = "Template";

    function asElement(element) {

      // find specified element
      if (element.constructor === String) {
        element = document.querySelector(element);
      }

      // it's a jQuery node
      if (element.constructor.name === 'oe') {
        element = element.get(0);
      }

      if (element instanceof Element && element.tagName === 'TEMPLATE') {
        element = element.content;
      }

      if (element instanceof DocumentFragment) {
        element = element.firstElementChild;
      }

      console.log(element);

      // element is already provided
      if (element instanceof Element) {
        return element;
      } else {
        throw new Error("An invalid or unknown document element node specified.");
      }
    }
    function query(object, property) {
      // original featured on gde33@freenode#javascript
      // https://jsfiddle.net/gaby_de_wilde/cthj49aw/4/

      var o;
      var q;

      o = object;
      q = property;

      keyset = (q.split(/[.{}]/g)).filter(function(e){return e});
      result = keyset.reduce(function(oo,nn){ return oo[nn]},o);

      return result;
    }
    prototype.setElement = function(element) {
        element = asElement(element);

        this.element = element;

        return element;
    };

    prototype.configureAddons = function() {
      this.mods = this.mods || {};
      this.mods.time = this.mods.time || {};
      this.mods.time.iso = function() {
        return (new Date()).toISOString();
      };
    };

    prototype.prepare = function(data) {
        var element, html, properties;

        element = this.element.cloneNode(true);
        html = element.innerHTML;
        properties = /\{([^}]+)\}/g;


        html = html.replace(properties, withValues);

        element.innerHTML = html;

        return element;

        function runAddon(capture) {
          var mod, func;

          mod = capture.split(":");
          func = mod.pop();
          mod = mod.shift();

          if (mods[mod] && mods[mod][func]) {
              return mods[mod][func](capture);
          }
        }

        function withValues(original, capture) {
          var module;
          var cache;

          if (capture.indexOf(":") !== -1) {
            module = runAddon(capture);

            if (module !== null && module !== undefined) {
              return module;
            }
          }

          return query(data, original) || original;
        }
    };

    function Template(element) {
      this.configureAddons();
      this.setElement(element);
    }

    return Template;
}());
{'fraction_non_alphanumeric': 0.12692656391659113, 'fraction_numerical': 0.0022665457842248413, 'mean_word_length': 1.7512468827930174, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '4281069', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1151, 'n_words': 265}