Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stempler compiled templates php closing tag ?> issue #1099

Open
Yoskaldyr opened this issue Apr 11, 2024 · 0 comments
Open

Stempler compiled templates php closing tag ?> issue #1099

Yoskaldyr opened this issue Apr 11, 2024 · 0 comments
Assignees
Labels

Comments

@Yoskaldyr
Copy link

Yoskaldyr commented Apr 11, 2024

Description

from php documentation:
https://www.php.net/manual/en/language.basic-syntax.instruction-separation.php

The closing tag for the block will include the immediately trailing newline if one is present

The first example shows the issue.
also this code https://3v4l.org/rc2sD

first line
<?php echo "second line"; ?>
third line

and this code https://3v4l.org/A9N8J

first line
<?php echo "second line"; ?>third line

generate the same output:

first line
second linethird line

but this code https://3v4l.org/ddCTm

first line
<?php echo "second line"; ?>

third line

generate proper output:

first line
second line
third line

Because all stempler compilers (directives, dynamic content) generate code as is and don't know about this:

The closing tag for the block will include the immediately trailing newline if one is present

How To Reproduce

we have this issue:
this template

line 1
hello {{ $name }}
line 3

compiles to this php

?>line 1
hello <?php echo htmlspecialchars((string) ($name), ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8'); ?>
line 3<?php

but render result for the name=Test will be:

line 1
hello Testline 3

expected behavior

line 1
hello Test
line 3

Additional Info

Q A
Framework Version 3.x

P.S. I don't know where is better to add trailing \n to all closing php tags ?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants