<commit_before><?php

use Disclosure\Injector;
use Disclosure\Container;
use Improse\View;

abstract class TwigView extends View
{
    use Injector;

    protected $twig;
    protected $template;
    
    public function __construct()
    {
        $this->inject(function ($adapter, $url, $twig) {});
    }
    
    public function __invoke(array $__viewdata = [])
    {
        return $this->twig->render($this->template, $__viewdata);
    }
}

TwigView::inject(function (&$twig) {
    $base = dirname(dirname(__DIR__));
    $loader = new Twig_Loader_Filesystem($base);
    $twig = new Twig_Environment($loader, [
        'cache' => "$base/.twig-cache",
    ]);
});
<commit_msg>fix twig view<commit_after><?php

namespace Monolyth;

use Disclosure\Injector;
use Disclosure\Container;
use Improse\View;

abstract class TwigView extends View
{
    use Injector;

    protected $twig;
    protected $template;
    
    public function __construct()
    {
        $this->inject(function ($twig) {});
    }
    
    public function __invoke(array $__viewdata = [])
    {
        return $this->twig->render($this->template, $__viewdata);
    }
}

/**
 * Example injection of Twig into your views (we don't want to make any
 * assumptions about your path structure etc.:
 */
/*
TwigView::inject(function (&$twig) {
    $loader = new Twig_Loader_Filesystem('/path/to/code');
    $twig = new Twig_Environment($loader, [
        'cache' => '/path/to/cache',
        'debug' => true|false,
        'auto_reload' => true|false,
    ]);
    
    // Example url function, assuming `$router` is available:
    $url = function ($name, array $args = []) use ($router) {
        if (!isset($_SERVER['SERVER_NAME'])) {
            $_SERVER['SERVER_NAME'] = 'http://localhost';
        }
        return $router->get($name)->url()->short(
            "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}",
            $args
        );
    };
    $twig->addFunction(new Twig_SimpleFunction('url', $url));
    
    // Example integration of Metaculous:
    $twig->addExtension(new Metaculous\TwigExtension(
        $arrayOfIgnoreWords,
        $hashOfRiggedWords
    ));
});
*/

{'fraction_non_alphanumeric': 0.15448658649398705, 'fraction_numerical': 0.0, 'mean_word_length': 2.8763440860215055, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '4286270', 'n_tokens_mistral': 686, 'n_tokens_neox': 687, 'n_words': 144}