Live data from Hacker News

Creating a PHP extension in Rust

jaredonline.svbtle.com

11–12 of 12 posts

Re: Creating a PHP extension in Rust

#11
post #10
post #9

Earlier quoted context omitted.

> When you use a templating engine, you can change the backend entirely without messing with the template. You can also compile/optimize the display of data in the template more easily. To be fair, all that you can do with a templating engine you can do "natively" as well. You can for example have code-less templates in PHP if you are disciplined enough to keep it that way. The only thing template engines do is enfor…

Sorry, should have clarified "code-less". I definitely don't like logic in templates (although React is making me re-think that as a strict policy). But I actually meant code as in any code. A line in PHP might be this: ">Some link So that "echo" is the code. And the same thing in Jinja is this: Some link In Jinja, it's only HTML + the names of variables (which I guess you could call "data"). I can now take that line…

For the record, your first example can be written in this manner with short tags on:

    ">Some link
Which is effectively pretty close to a templating pseudo-syntax.

Re: Creating a PHP extension in Rust

#12
post #11
post #10

Earlier quoted context omitted.

Sorry, should have clarified "code-less". I definitely don't like logic in templates (although React is making me re-think that as a strict policy). But I actually meant code as in any code. A line in PHP might be this: ">Some link So that "echo" is the code. And the same thing in Jinja is this: Some link In Jinja, it's only HTML + the names of variables (which I guess you could call "data"). I can now take that line…

For the record, your first example can be written in this manner with short tags on: ">Some link Which is effectively pretty close to a templating pseudo-syntax.

That's a perfect example of a bad practice that's done for readability in PHP templating.

Short tags are off by default in PHP (and have been for years), so you're losing some portability when you use them in your code. If, for example, someone reinstalls your PHP package and overwrites your config (which is very easy to do), your app suddenly breaks.

Post reply on HN