Re: [RFC Idea] Short echo tag with automatic HTML escaping (<?~ ... ?>)
| From: | Paul M. Jones | Date: | Wed, 24 Dec 2025 16:15:41 +0000 |
| Subject: | Re: [RFC Idea] Short echo tag with automatic HTML escaping (<?~ ... ?>) | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129688@lists.php.net to get a copy of this message | ||
Hi all,
> On Dec 24, 2025, at 02:14, Rob Landers <rob@bottled.codes> wrote:
>
> Maybe, you should consider something like this:
>
> <?:html: or <?:h:
> <?:attr:
> <?:url:
> <?:js:
> <?:css:
>
> Then you only choose the one for your context:
>
> const name = <?:js: $name ?>
>
> <a href="/search?q=<?:attr: $query ?>"...
>
> window.config=<?:js: $config ?>
>
> .size { width=<?:css: $width ?>; } //prevents ;}.size:after {
> content="<a..."
>
> Its a bit more to type, but compared to googling the right way to do these in all the right
> places and vetting/hoping that it is right... it seems worth it.
For what it's worth, that is much how Qiq works:
- {{ ... }} will not echo at all by itself
- {{= ... }} will echo raw unescaped output
- {{h ... }} will echo escaped for HTML content
- {{a ... }} will echo escaped for HTML attributes
- {{u ... }} will echo escaped for URLs
- {{c ... }} will echo escaped for CSS
- {{j ... }} will echo escaped for JavaScript
<https://qiqphp.com/3.x/syntax.html>
-- pmj