<commit_before>'use strict'

import R from 'ramda';
import React, {PropTypes} from 'react';
import Registry from './registry';
import NotifyObservers from './components/core/NotifyObservers.react';


export default function render(component, path=[]) {
    if (R.contains(R.type(component), ['String', 'Number', 'Null'])) {
        return component;
    }

    // Create list of child elements
    let children;

    const props = R.propOr({}, 'props', component);

    // TODO - Rename component.content to component.children
    if (!R.has('props', component) ||
        !R.has('content', component.props) ||
        typeof component.props.content === 'undefined') {

        // No children
        children = [];

    } else if (R.contains(R.type(component.props.content), ['String', 'Number', 'Null'])) {

        children = [component.props.content];

    } else {
        // One or multiple objects

        // Recursively render the tree
        const renderChild = (child, i) =>
            render(child, R.append(i, path))

        children = (Array.isArray(content) ? content : [content])
                   .map(renderChild);

    }

    const element = Registry.resolve(component.type, component.namespace);

    const parent = React.createElement(
        element,
        R.omit(['content'], component.props),
        ...children
    );

    return (
        <NotifyObservers id={props.id}>
            {parent}
        </NotifyObservers>
    );
}

render.propTypes = {
    content: PropTypes.object,
    id: PropTypes.string
}<commit_msg>don't need path in here<commit_after>'use strict'

import R from 'ramda';
import React, {PropTypes} from 'react';
import Registry from './registry';
import NotifyObservers from './components/core/NotifyObservers.react';


export default function render(component) {
    if (R.contains(R.type(component), ['String', 'Number', 'Null'])) {
        return component;
    }

    // Create list of child elements
    let children;

    const props = R.propOr({}, 'props', component);

    // TODO - Rename component.content to component.children
    if (!R.has('props', component) ||
        !R.has('content', component.props) ||
        typeof component.props.content === 'undefined') {

        // No children
        children = [];

    } else if (R.contains(R.type(component.props.content), ['String', 'Number', 'Null'])) {

        children = [component.props.content];

    } else {
        // One or multiple objects

        // Recursively render the tree
        children = (Array.isArray(props.content) ? props.content : [props.content])
                   .map(render);

    }

    const element = Registry.resolve(component.type, component.namespace);

    const parent = React.createElement(
        element,
        R.omit(['content'], component.props),
        ...children
    );

    return (
        <NotifyObservers id={props.id}>
            {parent}
        </NotifyObservers>
    );
}

render.propTypes = {
    content: PropTypes.object,
    id: PropTypes.string
}
{'fraction_non_alphanumeric': 0.14346965699208444, 'fraction_numerical': 0.0, 'mean_word_length': 2.5185614849187936, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5171234', 'n_tokens_mistral': 854, 'n_tokens_neox': 830, 'n_words': 214}