<commit_before>import _ from 'lodash';
// import t7 from 't7';

export default class TemplatePlugin {
  apply (component, source) {
    let render;

    t7.module(tag => {
      _.each(component.components, (c, k) => tag.assign(k, c.view));
      render = source.bind(null, tag);
    });

    component.view = function view (propsArg, ...children) {
      const props = _.omit(propsArg || {}, 'styles');
      const styles = _.defaults(props.styles || {}, component.styles);

      return render({
        actions: component.actions,
        state: component.state,       // <-- getter
        styles,
        props,
        children,
      });
    };
  }<commit_msg>t7 initially working but buggy<commit_after>import _ from 'lodash';
import t7 from '../../../t7'; global.t7 = t7;
import InfernoCreateElement from 'inferno-create-element';
import { extendHyperscript } from './ViewPlugin';

function transformAttributes (attrs, k) {
  const v = this[k];

  // Remove nil attributes
  if (v === null || v === void 0) return attrs;

  switch (k) {
    case 'onLoad': attrs.onAttached = v; break;
    case 'onUnload': attrs.onWillDetach = v; break;
    default: attrs[k] = v;
  }

  return attrs;
}

export const createElement = extendHyperscript(function infernoEl (tag, props, ...children) {
  const attrs = Object.keys(props || {}).reduce(_.bind(transformAttributes, props), {});
  return InfernoCreateElement(tag, attrs, ...children);
});

export default class TemplatePlugin {
  apply (component, source) {
    let render;

    const views = _.mapValues(component.components, (child, key) => {
      child.view.displayName = key;
      return child.view;
    });

    t7.setOutput(t7.Outputs.Universal);

    t7.module(tag => {
      _.each(views, (view, key) => tag.assign(key, view));
      render = source.bind(null, tag);
    });

    component.view = function view (propsArg, ...children) {
      const props = _.omit(propsArg || {}, 'styles');
      const styles = _.defaults(props.styles || {}, component.styles);

      return render({
        actions: component.actions,
        state: component.state,         // <- getter
        styles,
        components: views,
        props,
        children,
      });
    };
  }
{'fraction_non_alphanumeric': 0.1510533393097266, 'fraction_numerical': 0.005378753922008068, 'mean_word_length': 2.6892561983471075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '3925572', 'n_tokens_mistral': 683, 'n_tokens_neox': 668, 'n_words': 174}