<commit_before><?php
/**
 * Webino (http://webino.sk)
 *
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
 * @copyright   Copyright (c) 2012-2014 Webino, s. r. o. (http://webino.sk)
 * @author      <NAME> <<EMAIL>>
 * @license     BSD-3-Clause
 */

namespace WebinoDraw\Manipulator\Plugin;

use Zend\View\Renderer\PhpRenderer;

/**
 *
 */
class Render implements PreLoopPluginInterface
{
    /**
     * @var PhpRenderer
     */
    protected $renderer;

    /**
     * @param PhpRenderer $renderer
     */
    public function __construct(PhpRenderer $renderer)
    {
        $this->renderer = $renderer;
    }

    /**
     * @param PluginArgument $arg
     */
    public function preLoop(PluginArgument $arg)
    {
        $spec = $arg->getSpec();
        if (empty($spec['render'])) {
            return;
        }

        $translation    = $arg->getTranslation();
        $varTranslation = $translation->makeVarKeys(clone $translation);
        foreach ($spec['render'] as $key => $value) {
            $translation[$key] = $this->renderer->render($varTranslation->translateString($value));
        }
    }
}
<commit_msg>Updated Manipulator\Plugin\Render, changed to InLoopPlugin type to support snippet path variable for properties of each node<commit_after><?php
/**
 * Webino (http://webino.sk)
 *
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
 * @copyright   Copyright (c) 2012-2015 Webino, s. r. o. (http://webino.sk)
 * @author      <NAME> <<EMAIL>>
 * @license     BSD-3-Clause
 */

namespace WebinoDraw\Manipulator\Plugin;

use Zend\View\Renderer\PhpRenderer;

use WebinoDraw\Dom\Element;

/**
 * Class Render
 */
class Render extends AbstractPlugin implements InLoopPluginInterface
{
    /**
     * @var PhpRenderer
     */
    protected $renderer;

    /**
     * @param PhpRenderer $renderer
     */
    public function __construct(PhpRenderer $renderer)
    {
        $this->renderer = $renderer;
    }

    /**
     * @param PluginArgument $arg
     */
    public function inLoop(PluginArgument $arg)
    {
        $spec = $arg->getSpec();
        if (empty($spec['render'])) {
            return;
        }

        $node = $arg->getNode();
        if (!$node instanceof Element) {
            return;
        }

        $translation      = $arg->getTranslation();
        $translationClone = clone $translation;
        $nodeTranslation  = $this->createNodeTranslation($arg->getNode(), $arg->getSpec());
        $translationClone->merge($nodeTranslation->getArrayCopy());
        $varTranslation   = $translationClone->makeVarKeys();

        foreach ($spec['render'] as $key => $value) {
            $translation[$key] = $this->renderer->render($varTranslation->translateString($value));
        }
    }
}

{'fraction_non_alphanumeric': 0.14595941616233535, 'fraction_numerical': 0.006407974368102528, 'mean_word_length': 2.53904282115869, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, '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': '2969783', 'n_tokens_mistral': 829, 'n_tokens_neox': 826, 'n_words': 172}