Twig icon indicating copy to clipboard operation
Twig copied to clipboard

Short spaceless-like operator

Open Seldaek opened this issue 1 year ago • 3 comments

Replacing the usages of spaceless due to the deprecation, I was wondering what's the shortest way to remove spaces between two tags, and right now it seems to be {#--#}. I wonder if adding {#-#} as special operator for this would make sense? Or {-} even, I don't know. Just an idea..

Seldaek avatar Nov 07 '24 10:11 Seldaek

The issue is that {#-#} is already valid syntax, parsed as a comment using whitespace control on one of its side (probably on its left, but I haven't checked which side actually wins in practice).

Using {-} would be a huge BC break, as using it currently makes it part of the output of the template (it is not a Twig markup).

I think keeping {#--#} is probably the way to go here (or using {#-#} just before the second tag, so that there is no space to remove on the right)

stof avatar Nov 07 '24 15:11 stof

(probably on its left, but I haven't checked which side actually wins in practice)

a
{#-#} b
c

Is rendered as

a b
c
   

Looks like letf wins, indeed.

smnandre avatar Nov 09 '24 01:11 smnandre