Skip Menu |

This queue is for tickets about the Template-Declare CPAN distribution.

Report information
The Basics
Id: 61571
Status: resolved
Priority: 0/
Queue: Template-Declare

People
Owner: Nobody in particular
Requestors: khatar [...] phear.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: no indentation feature (patch attached)
Date: Wed, 22 Sep 2010 20:41:10 +0200
To: bug-template-declare [...] rt.cpan.org
From: Marc Chantreux <khatar [...] phear.org>
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

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #61571] no indentation feature (patch attached)
Date: Sun, 3 Oct 2010 22:25:52 -0400
To: Marc Chantreux via RT <bug-Template-Declare [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
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(" />");
Subject: Re: [rt.cpan.org #61571] no indentation feature (patch attached)
Date: Mon, 4 Oct 2010 10:20:59 +0200
To: Jesse via RT <bug-Template-Declare [...] rt.cpan.org>
From: Marc Chantreux <khatar [...] phear.org>
hello Jesse and thanks for reply, On Mon, Oct 04, 2010 at 02:01:10AM -0400, Jesse via RT wrote: Show quoted text
> Initially, I was somewhat disinclined to take this patch, but letting it > sit for a week has caused me to relent.
I wrote it because spaces are very bad for web design as </li><li> doesn't render the same as </li> <li> Another solution i use if i want to keep the indentation is to move the tag ending symbol on the next line: </li Show quoted text
><li>
Just tell me if you have a preference Show quoted text
> I'll take the patch if you can add a bit of perldoc and a test for it ;)
sure! is there a SCM somewhere? i wrote this patch on the stable cpan code which is not the best option. Show quoted text
> Thanks!
My pleasure, I planned to write something similar to Template::Declare when i discovered it so you saved a lot of my time. regards Marc
Subject: Re: [rt.cpan.org #61571] no indentation feature (patch attached)
Date: Thu, 4 Nov 2010 12:41:36 -0400
To: Marc Chantreux via RT <bug-Template-Declare [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
On Mon, Oct 04, 2010 at 04:21:22AM -0400, Marc Chantreux via RT wrote: Show quoted text
> Queue: Template-Declare > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=61571 > > > hello Jesse and thanks for reply, > > On Mon, Oct 04, 2010 at 02:01:10AM -0400, Jesse via RT wrote:
> > Initially, I was somewhat disinclined to take this patch, but letting it > > sit for a week has caused me to relent.
> > I wrote it because spaces are very bad for web design as > > </li><li> > > doesn't render the same as > > </li> > <li> > > Another solution i use if i want to keep the indentation is to move the > tag ending symbol on the next line: > > </li
> ><li>
> > Just tell me if you have a preference
I prefer </li><li>, I think. Show quoted text
> > I'll take the patch if you can add a bit of perldoc and a test for it ;)
> > sure! is there a SCM somewhere? i wrote this patch on the stable cpan > code which is not the best option.
Sorry! This got lost in my inbox. http://github.com/bestpractical should be what you want. Show quoted text
>
> > Thanks!
> > My pleasure, > I planned to write something similar to Template::Declare when i > discovered it so you saved a lot of my time. > > regards > Marc >
--
Subject: Re: [rt.cpan.org #61571] no indentation feature (patch attached)
Date: Thu, 2 Dec 2010 00:48:38 +0100
To: Jesse via RT <bug-Template-Declare [...] rt.cpan.org>
From: Marc Chantreux <khatar [...] phear.org>
Hi Jesse, fixed as asked and pull requested. https://github.com/bestpractical/template-declare/pull/1 next step could be to add a method "inline_render" or something to set the two values easily. just tell me ... regards marc
Subject: Re: [rt.cpan.org #61571] no indentation feature (patch attached)
Date: Mon, 06 Dec 2010 11:53:43 -0500
To: bug-template-declare [...] rt.cpan.org
From: Thomas Sibley <trs [...] bestpractical.com>
Thanks! I've merged and pushed your commits. Thomas