<commit_before><?php
/**
 * Created by PhpStorm.
 * User: BBN
 * Date: 07/12/2014
 * Time: 18:26
 */

namespace bbn;

if ( !defined('BBN_DATA_PATH') ){
  die("BBN_DATA_PATH must be defined");
}

class tpl {

  static private $engine, $tmp;

  static private function _init(){

  }

  static public function renderer($st){
    self::_init();
    if ( !is_string($st) ){
      die("The template parameter is not a string");
    }
    $md5 = md5($st);
    $file = BBN_DATA_PATH.'tmp/tpl.'.$md5.'.php';
    if ( file_exists($file) ){
      return include($file);
    }
    $tpl = \LightnCandy\LightnCandy::compile($st, [
      'flags' => \LightnCandy\LightnCandy::FLAG_MUSTACHELOOKUP |
        \LightnCandy\LightnCandy::FLAG_PARENT |
        \LightnCandy\LightnCandy::FLAG_HANDLEBARSJS |
        \LightnCandy\LightnCandy::FLAG_ERROR_LOG
    ]);
    file_put_contents($file, $tpl);
    return include($file);
  }

  static public function render($st, $data){
    self::_init();
    if ( is_callable($tpl = self::renderer($st)) ) {
      return $tpl($data);
    }
    return '';
  }

} <commit_msg>Bugfix in template (for LightnCandy new version)<commit_after><?php
namespace bbn;

if ( !defined('BBN_DATA_PATH') ){
  die("BBN_DATA_PATH must be defined");
}

class tpl {

  static private $engine, $tmp;

  static private function _init(){

  }

  static public function renderer($st){
    self::_init();
    if ( !is_string($st) ){
      die("The template parameter is not a string");
    }
    $md5 = md5($st);
    $file = BBN_DATA_PATH.'tmp/tpl.'.$md5.'.php';
    if ( file_exists($file) ){
      return include($file);
    }

    $tpl = \LightnCandy\LightnCandy::compile($st, [
      'flags' => \LightnCandy\LightnCandy::FLAG_MUSTACHELOOKUP |
        \LightnCandy\LightnCandy::FLAG_PARENT |
        \LightnCandy\LightnCandy::FLAG_HANDLEBARSJS |
        \LightnCandy\LightnCandy::FLAG_ERROR_LOG
    ]);
    return \LightnCandy\LightnCandy::prepare($tpl);
  }

  static public function render($st, $data){
    self::_init();
    if ( is_callable($tpl = self::renderer($st)) ) {
      return $tpl($data);
    }
    return '';
  }
}
{'fraction_non_alphanumeric': 0.16086547507055504, 'fraction_numerical': 0.008466603951081843, 'mean_word_length': 3.1705882352941175, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3549428', 'n_tokens_mistral': 785, 'n_tokens_neox': 776, 'n_words': 141}