<commit_before><?php

namespace MtHaml\Support\Twig;

use MtHaml\Environment;

class Loader implements \Twig_LoaderInterface
{
    protected $env;
    protected $loader;

    public function __construct(Environment $env, \Twig_LoaderInterface $loader)
    {
        $this->env = $env;
        $this->loader = $loader;
    }

    public function getSource($name)
    {
        $source = $this->loader->getSource($name);
        if (strncmp($source, '{% haml %}', 10) === 0) {
            $source = substr($source, 10);
            $source = $this->env->compileString($source, $name);
        }
        return $source;
    }

    public function getCacheKey($name)
    {
        return $this->loader->getCacheKey($name);
    }

    public function isFresh($name, $time)
    {
        return $this->loader->isFresh($name, $time);
    }

    public function setPaths($paths)
    {
        if (method_exists($this->loader, 'setPaths')) {
            $this->loader->setPaths($paths);
        }
    }
} 
<commit_msg>allow whitespaces before {% haml %}<commit_after><?php

namespace MtHaml\Support\Twig;

use MtHaml\Environment;

class Loader implements \Twig_LoaderInterface
{
    protected $env;
    protected $loader;

    public function __construct(Environment $env, \Twig_LoaderInterface $loader)
    {
        $this->env = $env;
        $this->loader = $loader;
    }

    public function getSource($name)
    {
        $source = $this->loader->getSource($name);
        if (preg_match('#\s*{%\s*haml\s*%}#', $source, $match)) {
            $source = substr($source, strlen($match[0]));
            $source = $this->env->compileString($source, $name);
        }
        return $source;
    }

    public function getCacheKey($name)
    {
        return $this->loader->getCacheKey($name);
    }

    public function isFresh($name, $time)
    {
        return $this->loader->isFresh($name, $time);
    }

    public function setPaths($paths)
    {
        if (method_exists($this->loader, 'setPaths')) {
            $this->loader->setPaths($paths);
        }
    }
} 

{'fraction_non_alphanumeric': 0.15351089588377723, 'fraction_numerical': 0.0029055690072639223, 'mean_word_length': 2.4722689075630253, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '503887', 'n_tokens_mistral': 661, 'n_tokens_neox': 636, 'n_words': 123}