From a6ef998abc0af8116d712297407cf2d980463efa Mon Sep 17 00:00:00 2001 From: "Paul Buetow (pluto.buetow.org)" Date: Sun, 29 Sep 2013 04:40:13 +0200 Subject: add flag support --- Xerl/Page/Content.pm | 66 ++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 30 deletions(-) (limited to 'Xerl/Page') diff --git a/Xerl/Page/Content.pm b/Xerl/Page/Content.pm index 578c254..5969ff0 100644 --- a/Xerl/Page/Content.pm +++ b/Xerl/Page/Content.pm @@ -12,6 +12,8 @@ use warnings; use v5.14.0; +use Data::Dumper; + use Xerl::Base; use Xerl::Page::Rules; use Xerl::Setup::Configure; @@ -36,7 +38,7 @@ sub parse($) { my Xerl::Page::Rules $rules = Xerl::Page::Rules->new( config => $config ); $rules->parse( $config->get_xmlconfigrootobj() ) - unless $config->exists('noparse'); + unless $config->exists('noparse'); $config->insertxmlvars( $config->get_xmlconfigrootobj() ); $self->insertrules( $rules, $xmlcontent->get_root() ); @@ -59,12 +61,12 @@ sub insertrules($$$$) { my $params = $element->get_params(); unshift @content, "Content-Type: $params->{type}\n\n" - if ref $params eq 'HASH' and exists $params->{type}; + if ref $params eq 'HASH' and exists $params->{type}; push @content, $self->_insertrules( $rules, $element ); $self->set_content( \@content ); - return undef; +return undef; } sub _insertrules($$$) { @@ -115,15 +117,19 @@ sub _insertrules($$$) { else { # No rule available, use the tag unmodified! - $name =~ s/^=//o; # Remove the leading = if ( $succ->get_single() ) { push @content, "<$name" . ( $succ->params_str() || '' ) . " />\n" } else { - push @content, + if ($succ->get_flag_noendtag() == 1) { + push @content, + "<$name" . ( $succ->params_str() || '' ) . ">\n"; + } else { + push @content, "<$name" . ( $succ->params_str() || '' ) . '>', $self->_insertrules( $rules, $succ ), $text, "\n"; + } } } @@ -140,38 +146,38 @@ sub _insertrules($$$) { my ( $orule, $crule ) = ( $rule->[0], $rule->[1] ); $self->_insert_special_vars( $rules, $succ, \$orule ); - $self->_insert_special_vars( $rules, $succ, \$crule ); - chomp $orule; + $self->_insert_special_vars( $rules, $succ, \$crule ); + chomp $orule; - # Parse for known tag params. - if ( ref $params eq 'HASH' ) { - Xerl::Page::Templates::PARSELINE( $config, '%%', \$text ); + # Parse for known tag params. + if ( ref $params eq 'HASH' ) { + Xerl::Page::Templates::PARSELINE( $config, '%%', \$text ); - # path/to/file.bla => file.bla - $text =~ s#.*/(.*)$#$1# if lc $params->{basename} eq 'yes'; + # path/to/file.bla => file.bla + $text =~ s#.*/(.*)$#$1# if lc $params->{basename} eq 'yes'; - # foo.bar.tld?options => ?options - if ( exists $params->{cut} ) { - my $cut = quotemeta $params->{cut}; - $text =~ s/.*$cut(.*)$/$1/o; - } + # foo.bar.tld?options => ?options + if ( exists $params->{cut} ) { + my $cut = quotemeta $params->{cut}; + $text =~ s/.*$cut(.*)$/$1/o; + } - $text .= $params->{addback} - if exists $params->{addback}; - $text = $params->{addfront} . $text - if exists $params->{addfront}; - } + $text .= $params->{addback} + if exists $params->{addback}; + $text = $params->{addfront} . $text + if exists $params->{addfront}; +} - my $oadd = - exists $ruleparams->{addfront} - ? '<' . $ruleparams->{addfront} - : ''; +my $oadd = +exists $ruleparams->{addfront} +? '<' . $ruleparams->{addfront} +: ''; - my $cadd = - exists $ruleparams->{addback} ? $ruleparams->{addback} . '>' : ''; +my $cadd = +exists $ruleparams->{addback} ? $ruleparams->{addback} . '>' : ''; - push @content, $orule, $oadd, $self->_insertrules( $rules, $succ ), - $text, $cadd, $crule; +push @content, $orule, $oadd, $self->_insertrules( $rules, $succ ), +$text, $cadd, $crule; } } -- cgit v1.2.3