<commit_before><?php

namespace Wasp\Templating\Engines;

use Symfony\Component\Templating\EngineInterface;
use \Twig_Loader_Filesystem as Loader;
use \Twig_Environment as Environment;

/**
 * Custom engine for twig templating
 *
 * @package Wasp
 * @subpackage Templating
 * @author <NAME>
 */
class TwigEngine implements EngineInterface
{
    /**
     * Filesystem loader
     *
     * @var Object
     */
    protected $loader;

    /**
     * Twig environment
     *
     * @var Object
     */
    protected $environment;

    /**
     * Instance of the FileSystem
     *
     * @var \Symfony\Component\Filesystem\Filesystem
     **/
    protected $fs;

    /**
     * Instance of the template class
     *
     * @var \Wasp\Templating\Template
     **/
    protected $template;

    /**
     * An instance of the container
     *
     * @var \Symfony\Component\DependencyInjection\ContainerBuilder
     */
    protected $container;

    /**
     * Load dependencies
     *
     * @param \Wasp\Templating\Template $template $template
     * @param \Symfony\Component\Filesystem\Filesystem $fs
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
     * @author <NAME>
     **/
    public function __construct($template, $fs, $container)
    {
        $this->template = $template;
        $this->fs = $fs;
        $this->container = $container;
    }

    /**
     * Creates the environment
     *
     * @param Array $settings
     * @return void
     * @author <NAME>
     */
    public function create(Array $settings = array())
    {
        $this->loader = new Loader($this->template->getDirectory());
        $this->environment = new Environment($this->loader, $settings);

        // Add Globals
        $this->environment->addGlobal('app', $this->container);
    }

    /**
     * Check if twig supports this file
     *
     * @param String $name
     * @return Boolean
     * @author <NAME>
     */
    public function supports($name)
    {
        return (strstr($name, '.twig') !== false);
    }

    /**
     * Check if the file exists
     *
     * @param String $name
     * @return Boolean
     * @author <NAME>
     */
    public function exists($name)
    {
        foreach ($this->template->getDirectory() as $temp) {
            if ($this->fs->exists($temp . $name)) {
                return true;
            }<commit_msg>Added assets as a twig global<commit_after><?php

namespace Wasp\Templating\Engines;

use Symfony\Component\Templating\EngineInterface;
use \Twig_Loader_Filesystem as Loader;
use \Twig_Environment as Environment;

/**
 * Custom engine for twig templating
 *
 * @package Wasp
 * @subpackage Templating
 * @author <NAME>
 */
class TwigEngine implements EngineInterface
{
    /**
     * Filesystem loader
     *
     * @var Object
     */
    protected $loader;

    /**
     * Twig environment
     *
     * @var Object
     */
    protected $environment;

    /**
     * Instance of the FileSystem
     *
     * @var \Symfony\Component\Filesystem\Filesystem
     **/
    protected $fs;

    /**
     * Instance of the template class
     *
     * @var \Wasp\Templating\Template
     **/
    protected $template;

    /**
     * An instance of the container
     *
     * @var \Symfony\Component\DependencyInjection\ContainerBuilder
     */
    protected $container;

    /**
     * Load dependencies
     *
     * @param \Wasp\Templating\Template $template $template
     * @param \Symfony\Component\Filesystem\Filesystem $fs
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
     * @author <NAME>
     **/
    public function __construct($template, $fs, $container)
    {
        $this->template = $template;
        $this->fs = $fs;
        $this->container = $container;
    }

    /**
     * Creates the environment
     *
     * @param Array $settings
     * @return void
     * @author <NAME>
     */
    public function create(Array $settings = array())
    {
        $this->loader = new Loader($this->template->getDirectory());
        $this->environment = new Environment($this->loader, $settings);

        // Add Globals
        $this->environment->addGlobal('app', $this->container);
        $this->environment->addGlobal('assets', $this->container->get('assets'));
    }

    /**
     * Check if twig supports this file
     *
     * @param String $name
     * @return Boolean
     * @author <NAME>
     */
    public function supports($name)
    {
        return (strstr($name, '.twig') !== false);
    }

    /**
     * Check if the file exists
     *
     * @param String $name
     * @return Boolean
     * @author <NAME>
     */
    public function exists($name)
    {
        foreach ($this->template->getDirectory() as $temp) {
            if ($this->fs->exists($temp . $name)) {
                return true;
            }
{'fraction_non_alphanumeric': 0.13041683862979778, 'fraction_numerical': 0.0, 'mean_word_length': 2.1311369509043927, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 47, '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': '3208407', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1402, 'n_words': 329}