Marc,
Initially, I was somewhat disinclined to take this patch, but letting it
sit for a week has caused me to relent.
I'll take the patch if you can add a bit of perldoc and a test for it ;)
Thanks!
Jesse
On Wed 22.Sep'10 at 14:41:29 -0400, Marc Chantreux via RT wrote:
Show quoted text> Wed Sep 22 14:41:28 2010: Request 61571 was acted upon.
> Transaction: Ticket created by khatar@phear.org
> Queue: Template-Declare
> Subject: no indentation feature (patch attached)
> Broken in: (no value)
> Severity: (no value)
> Owner: Nobody
> Requestors: khatar@phear.org
> Status: new
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=61571 >
>
>
> hello,
>
> This patch adds the $EOL and $TAG_INDENTATION variables to control the
> indentation flow:
>
> <html>
> <body>
> <p>pouet</p>
> </body>
> </html>
>
> becomes
>
> <html><body><p>pouet</p></body></html>
>
> when i add in my source:
>
> $Template::Declare::Tags::TAG_INDENTATION = 0;
> $Template::Declare::Tags::EOL = "";
>
> regards
> marc
>
Show quoted text> diff --git a/lib/Template/Declare/Tags.pm b/lib/Template/Declare/Tags.pm
> index 87d3ffc..d153ebc 100644
> --- a/lib/Template/Declare/Tags.pm
> +++ b/lib/Template/Declare/Tags.pm
> @@ -33,6 +33,8 @@ our @TagSubs;
> our %ATTRIBUTES = ();
> our %ELEMENT_ID_CACHE = ();
> our $TAG_NEST_DEPTH = 0;
> +our $TAG_INDENTATION = 1;
> +our $EOL = "\n";
> our @TEMPLATE_STACK = ();
>
> our $SKIP_XML_ESCAPING = 0;
> @@ -600,7 +602,7 @@ of a template based on attributes passed to C<with>.
> sub smart_tag_wrapper (&) {
> my $coderef = shift;
>
> - Template::Declare->buffer->append("\n");
> + Template::Declare->buffer->append($EOL);
> Template::Declare->buffer->push( from => "T::D tag wrapper", private => 1 );
>
> my %attr = %ATTRIBUTES;
> @@ -710,7 +712,7 @@ sub xml_decl (&;$) {
> while ( my ( $field, $val ) = splice( @rv, 0, 2 ) ) {
> outs_raw(qq/ $field="$val"/);
> }
> - outs_raw("?>\n");
> + outs_raw("?>$EOL");
> return @_;
> }
>
> @@ -766,7 +768,7 @@ sub _tag {
> $tag = $tagset->namespace . ":$tag" if defined $tagset->namespace;
>
> Template::Declare->buffer->append(
> - "\n"
> + $EOL
> . ( " " x $TAG_NEST_DEPTH )
> . "<$tag"
> . join( '',
> @@ -802,7 +804,7 @@ sub _tag {
> wantarray ? () : '';
> };
>
> - local $TAG_NEST_DEPTH = $TAG_NEST_DEPTH + 1;
> + local $TAG_NEST_DEPTH = $TAG_NEST_DEPTH + $TAG_INDENTATION;
> %ATTRIBUTES = ();
> Template::Declare->buffer->push( private => 1, from => "T::D tag $tag" );
> $last = join '', map { ref($_) && $_->isa('Template::Declare::Tag') ? $_ : _postprocess($_) } $code->();
> @@ -813,7 +815,7 @@ sub _tag {
>
> if (length $content) {
> Template::Declare->buffer->append(">$content");
> - Template::Declare->buffer->append("\n" . ( " " x $TAG_NEST_DEPTH )) if $content =~ /\</;
> + Template::Declare->buffer->append( $EOL . ( " " x $TAG_NEST_DEPTH )) if $content =~ /\</;
> Template::Declare->buffer->append("</$tag>");
> } elsif ( $tagset->can_combine_empty_tags($tag) ) {
> Template::Declare->buffer->append(" />");