File Coverage

blib/lib/Text/MustacheTemplate.pm
Criterion Covered Total %
statement 27 27 100.0
branch 4 4 100.0
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 41 41 100.0


line stmt bran cond sub pod time code
1             package Text::MustacheTemplate;
2 13     13   2190444 use 5.022000;
  13         55  
3 13     13   65 use strict;
  13         22  
  13         336  
4 13     13   74 use warnings;
  13         42  
  13         1142  
5              
6             our $VERSION = "0.04";
7              
8 13     13   5859 use Text::MustacheTemplate::Lexer;
  13         44  
  13         773  
9 13     13   6817 use Text::MustacheTemplate::Parser;
  13         67  
  13         828  
10 13     13   7225 use Text::MustacheTemplate::Compiler;
  13         48  
  13         3192  
11              
12             our $OPEN_DELIMITER;
13             our $CLOSE_DELIMITER;
14             our %REFERENCES;
15             our $LAMBDA_TEMPLATE_RENDERING = 0;
16              
17             sub parse {
18 505     505 1 2927514 my ($class, $source) = @_;
19 505 100       1834 local $Text::MustacheTemplate::Lexer::OPEN_DELIMITER = $OPEN_DELIMITER if defined $OPEN_DELIMITER;
20 505 100       1251 local $Text::MustacheTemplate::Lexer::CLOSE_DELIMITER = $CLOSE_DELIMITER if defined $CLOSE_DELIMITER;
21 505         2160 my @tokens = Text::MustacheTemplate::Lexer->tokenize($source);
22 499         1270 local $Text::MustacheTemplate::Parser::SOURCE = $source;
23 499         2056 my $ast = Text::MustacheTemplate::Parser->parse(@tokens);
24 491         2617 return Text::MustacheTemplate::Compiler->compile($ast);
25             }
26              
27             sub render {
28 193     193 1 775873 my ($class, $source, $context) = @_;
29 193         760 local @Text::MustacheTemplate::Compiler::CONTEXT_HINT = ($context);
30 193         802 return $class->parse($source)->($context);
31             }
32              
33             1;
34             __END__