DTL-Fast
view release on metacpan or search on metacpan
lib/DTL/Fast/Entity.pm view on Meta::CPAN
package DTL::Fast::Entity;
use strict;
use utf8;
use warnings FATAL => 'all';
# prototype for template entity. Handling current line and current template references
use Scalar::Util qw(weaken);
use Carp qw(confess);
sub new
{
my ( $proto, %kwargs ) = @_;
$proto = ref $proto || $proto;
$DTL::Fast::Template::CURRENT_TEMPLATE->{modules}->{$proto} = $proto->VERSION // DTL::Fast->VERSION;
lib/DTL/Fast/Entity.pm view on Meta::CPAN
return $self;
}
sub remember_template
{
my ($self) = @_;
$self->{_template} = $DTL::Fast::Template::CURRENT_TEMPLATE;
$self->{_template_line} = $DTL::Fast::Template::CURRENT_TEMPLATE_LINE;
weaken $self->{_template};
return $self;
}
sub get_parse_error
{
my ($self, $message, @messages) = @_;
return $self->compile_error_message(
'Parsing error' => $message // 'undef'
lib/DTL/Fast/FilterManager.pm view on Meta::CPAN
package DTL::Fast::FilterManager;
use strict;
use utf8;
use warnings FATAL => 'all';
use parent 'DTL::Fast::Replacer';
use DTL::Fast::Template;
use Scalar::Util qw(weaken);
sub new
{
my ( $proto, %kwargs ) = @_;
$proto = ref $proto || $proto;
my $self = $proto->SUPER::new(
filters => [ ],
filters_number => 0,
replacement => $kwargs{replacement}, # if strings were back-uped before
);
if ($self->{replacement})
{
weaken($self->{replacement});
}
if ($kwargs{filters})
{
if (ref $kwargs{filters} eq 'ARRAY')
{
$self->add_filters($kwargs{filters});
}
else
{
lib/DTL/Fast/Template.pm view on Meta::CPAN
package DTL::Fast::Template;
use parent 'DTL::Fast::Parser';
use strict;
use utf8;
use warnings FATAL => 'all';
use DTL::Fast qw(get_template);
use DTL::Fast::Context;
use DTL::Fast::Tags;
use DTL::Fast::Filters;
use Scalar::Util qw/weaken/;
our $CURRENT_TEMPLATE; # global variable for linking modules
our $CURRENT_TEMPLATE_LINE; # global variable for source line number
#@Override
sub new
{
my ( $proto, $template, %kwargs ) = @_;
$template //= '';
lib/DTL/Fast/Template.pm view on Meta::CPAN
return $self;
}
#@Override self-linking
sub remember_template
{
my ($self) = @_;
$self->{_template} = $self;
$self->{_template_line} = 1;
weaken $self->{_template};
return $self;
}
#@Override
sub parse_chunks
{
my ( $self ) = @_;
my ( $current_template_backup, $current_template_line_backup ) = ($CURRENT_TEMPLATE, $CURRENT_TEMPLATE_LINE);
lib/DTL/Fast/Text.pm view on Meta::CPAN
package DTL::Fast::Text;
use strict;
use utf8;
use warnings FATAL => 'all';
use DTL::Fast::Template;
use Scalar::Util qw/weaken/;
sub new
{
my ($proto, $text ) = @_;
$text //= '';
my $self = bless {
texts => [ $text ]
, _template => $DTL::Fast::Template::CURRENT_TEMPLATE
, _template_line => $DTL::Fast::Template::CURRENT_TEMPLATE_LINE
}, $proto;
weaken $self->{_template};
return $self;
}
sub append
{
my $self = shift;
$self->{need_join} ||= 1;
push @{$self->{texts}}, shift;
return $self;
( run in 0.712 second using v1.01-cache-2.11-cpan-65fba6d93b7 )