<commit_before><?php
include "lightncandy.php";

class Blitz {

    /**
     * Load a template.
     *
     * @param string $body Blitz template body
     *
     * @return void
     */
    public function load ($body) {
        $preparedBody = $this->prepare ($body);
//        echo $preparedBody . "\n\n";
        $this->code = LightnCandy::compile ($preparedBody, ["flags" =>
            LightnCandy::FLAG_BLITZ |
            LightnCandy::FLAG_BARE |        // compile to function, that don't print rendered data to screen, but return it as a string
            LightnCandy::FLAG_MUSTACHESP |  // remove spaces and linebreaks around context tags
            LightnCandy::FLAG_SPVARS |      // _num, _first, _last
            LightnCandy::FLAG_PARENT |      // _parent
            LightnCandy::FLAG_ELSE |        // enables else tag
            LightnCandy::FLAG_NOESCAPE |    // no html-escaping
            LightnCandy::FLAG_GLOBALS |
            LightnCandy::FLAG_ERROR_LOG
        ]);
        $this->renderer = eval ($this->code);
    }

    /**
     * Render loaded template with data from $vars and print it.
     *
     * @param array() $vars Data to render the template.
     *
     * @return void
     */
    public function display ($vars = null) {
        echo $this->parse ($vars);
    }

    /**
     * Render loaded template with data from $vars and return it.
     *
     * @param array() $vars Data to render the template.
     *
     * @return void
     */
    public function parse ($vars = null) {
        if ($vars !== null)
            $this->set ($vars);
        $renderer = $this->renderer;    //PHP bug
        return $renderer($this->vars, null, $this, $this->globals);
    }

    /**
     * @param array() $vars Data to render the template.
     */
    public function set ($vars) {
        $this->vars = array_merge($this->vars, $vars);
    }

    /**
     * @param array() $vars Global data to render the template.
     */
    public function setGlobals ($vars) {
        $this->globals = $vars;
    }

    public function clean () {
        $this->vars = [];
    }
<commit_msg>added constructor and setGlobals() alias<commit_after><?php
include "lightncandy.php";

class Blitz {

    /**
     * Load a template file.
     */
    function __construct ($filename = NULL) {
        if (isset ($filename))
            $this->load (file_get_contents ($filename));
    }

    /**
     * Load a template.
     *
     * @param string $body Blitz template body
     *
     * @return void
     */
    public function load ($body) {
        $preparedBody = $this->prepare ($body);
//        echo $preparedBody . "\n\n";
        $this->code = LightnCandy::compile ($preparedBody, ["flags" =>
            LightnCandy::FLAG_BLITZ |
            LightnCandy::FLAG_BARE |        // compile to function, that don't print rendered data to screen, but return it as a string
            LightnCandy::FLAG_MUSTACHESP |  // remove spaces and linebreaks around context tags
            LightnCandy::FLAG_SPVARS |      // _num, _first, _last
            LightnCandy::FLAG_PARENT |      // _parent
            LightnCandy::FLAG_ELSE |        // enables else tag
            LightnCandy::FLAG_NOESCAPE |    // no html-escaping
            LightnCandy::FLAG_GLOBALS |
            LightnCandy::FLAG_ERROR_LOG
        ]);
        $this->renderer = eval ($this->code);
    }

    /**
     * Render loaded template with data from $vars and print it.
     *
     * @param array() $vars Data to render the template.
     *
     * @return void
     */
    public function display ($vars = null) {
        echo $this->parse ($vars);
    }

    /**
     * Render loaded template with data from $vars and return it.
     *
     * @param array() $vars Data to render the template.
     *
     * @return void
     */
    public function parse ($vars = null) {
        if ($vars !== null)
            $this->set ($vars);
        $renderer = $this->renderer;    //PHP bug
        return $renderer($this->vars, null, $this, $this->globals);
    }

    /**
     * @param array() $vars Data to render the template.
     */
    public function set ($vars) {
        $this->vars = array_merge($this->vars, $vars);
    }

    /**
     * @param array() $vars Global data to render the template.
     */
    public function setGlobals ($vars) {
        $this->globals = $vars;
    }

    /**
     * Alias for setGlobals()
     */
    public function setGlobal ($vars) {
        $this->setGlobals ($vars);
    }

    public function clean () {
        $this->vars = [];
    }

{'fraction_non_alphanumeric': 0.12886937431394072, 'fraction_numerical': 0.0, 'mean_word_length': 1.894536213468869, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '2429696', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1339, 'n_words': 377}