abw / Template2

Perl Template Toolkit v2
http://template-toolkit.org/
146 stars 94 forks source link

Outline tags must be placed at the start of the line #320

Closed bbrtj closed 3 months ago

bbrtj commented 4 months ago

The examples in https://template-toolkit.org/docs/manual/Syntax.html show that outline tags are placed with whitespace between them and start of the line. I've spent hours debugging this and seems like they must be placed exactly at the start of the line to be parsed correctly.

I would assume outline tags take everything from where they are put to the end of the line, but I'm also fine with the scenario where the line must only have whitespace before an outline tag.

Workaround: set outline tag to qr{\V*%%}

abw commented 4 months ago

My apologies for the confusion, but that's a formatting error in the website examples. It looks like the conversion from the POD source to HTML has introduced some extra whitespace.

The outline tags should be right at the start of the line, with no whitespace permitted.

bbrtj commented 4 months ago

In that case, two things:

bbrtj commented 4 months ago

Overall, I think outline tags at the start of the line look kind of weird if you use any indenting for your template. I would love if my PR would be merged to make that a default. Other than a very small risk of breaking some templates (where a developer deliberately started some lines with %% after whitespace and intended them to not be parsed by TT), are there reasons not to do this?

abw commented 3 months ago

It's possible (if unlikely) that it might break existing templates and that always makes me nervous.

Given that there's already a work-around which allows you to implement this, I think we're going to have to pass on this for now.

I'd be happy to reconsider it if it was switchable using a config option, e.g. INDENT_OUTLINE_TAGS. But then, if you need to set a config option to enable it then perhaps it's just as easy to use the work-around and set the outline tags to qr{\V*%%}?