Re: Re: Adding new closing tag =?> for keeping trailing newline
| From: | shinji igarashi | Date: | Wed, 08 Jun 2022 18:15:46 +0000 |
| Subject: | Re: Re: Adding new closing tag =?> for keeping trailing newline | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117878@lists.php.net to get a copy of this message | ||
> declare(ignore_newline_after_close_tag=false);
Thanks for coming up with another idea!
As others have already pointed out, disabling the closing tag from
eating trailing newline throughout the file would be inconvenient if
we want to use control statements in the template.
However, we currently only have one closing tag, but we already
have two opening tags. So, for example, if we use declare to disable
the newline eating only when closing a PHP block started with `<?=',
it can produce the desired output.
<?php declare(ignore_newline_after_closing_short_tag=false) ?>
<?php foreach ([1, 2, 3] as $item): ?>
- <? = $item ?>
<?php endforeach ?>
I'm honestly not sure if adding a declare switch is better received
than a new closing tag, though.
Thanks!
--
Shinji Igarashi
2022年6月8日(水) 12:34 Sara Golemon <pollita@php.net>:
>
> On Tue, Jun 7, 2022 at 10:27 AM Robert Landers <landers.robert@gmail.com> wrote:
> > FWIW, I think it makes a lot of sense, having used golang's template
> > language (not everyone is generating HTML with PHP). I think you may
> > just be dealing with a vocal minority and it would be worth putting to
> > an actual vote. Even if it fails, we'll learn something the next time
> > someone wants to change something like this.
> >
>
> While my gut response for the new end tag is in the "no" column, I do wonder if we
> can accommodate "non-html" scenarios in a broader (maybe more palatable?) way by assuming
> that if you want the newline to be respected on one line, you probably want it that way for the
> whole file.
>
> <?php
> declare(ignore_newline_after_close_tag=false); // defaults to true, i.e existing behavior
>
> This would avoid any new syntax rules, but still provide the ability for php-as-template-engine
> to behave in the user's preferred mode.
>
> -Sara