<commit_before>package Mojolicious::Plugin::EPRenderer;
use Mojo::Base 'Mojolicious::Plugin';

use Mojo::Template;
use Mojo::Util qw(encode md5_sum monkey_patch steady_time);

sub register {
  my ($self, $app, $conf) = @_;

  # Auto escape by default to prevent XSS attacks
  my $template = {auto_escape => 1, %{$conf->{template} || {}}};

  # Add "ep" handler and make it the default
  $app->renderer->default_handler('ep')->add_handler(
    $conf->{name} || 'ep' => sub {
      my ($renderer, $c, $output, $options) = @_;

      # Generate name
      my $name = $options->{inline} || $renderer->template_name($options);
      return undef unless defined $name;
      my @keys = sort grep {/^\w+$/} keys %{$c->stash};
      my $id = encode 'UTF-8', join(',', $name, @keys);
      my $key = $options->{cache} = md5_sum $id;

      # Cache template for "epl" handler
      my $cache = $renderer->cache;
      my $mt    = $cache->get($key);
      unless ($mt) {
        $mt = Mojo::Template->new($template);

        # Helpers (only once)<commit_msg>steady_time seems to be no important import<commit_after>package Mojolicious::Plugin::EPRenderer;
use Mojo::Base 'Mojolicious::Plugin';

use Mojo::Template;
use Mojo::Util qw(encode md5_sum monkey_patch);

sub register {
  my ($self, $app, $conf) = @_;

  # Auto escape by default to prevent XSS attacks
  my $template = {auto_escape => 1, %{$conf->{template} || {}}};

  # Add "ep" handler and make it the default
  $app->renderer->default_handler('ep')->add_handler(
    $conf->{name} || 'ep' => sub {
      my ($renderer, $c, $output, $options) = @_;

      # Generate name
      my $name = $options->{inline} || $renderer->template_name($options);
      return undef unless defined $name;
      my @keys = sort grep {/^\w+$/} keys %{$c->stash};
      my $id = encode 'UTF-8', join(',', $name, @keys);
      my $key = $options->{cache} = md5_sum $id;

      # Cache template for "epl" handler
      my $cache = $renderer->cache;
      my $mt    = $cache->get($key);
      unless ($mt) {
        $mt = Mojo::Template->new($template);

        # Helpers (only once)
{'fraction_non_alphanumeric': 0.18070009460737937, 'fraction_numerical': 0.003784295175023652, 'mean_word_length': 3.2641129032258065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '4369139', 'n_tokens_mistral': 727, 'n_tokens_neox': 711, 'n_words': 198}