Comments (4)
Hi,
- I agree with you, it seems like this check doesn't make sense any more after 6bb3025
2a. I can only imagine a strange case when due to race condition the template file does no longer exist after it has been checked on L149 but before it's actually included. With require you will still get an exception in this case. But I'm sure there must have been a more simple reason, also it's possible that the check was added later, didn't check the actual commit log.
2b. try/catch wraps the required template, rather than extract, and is used to not allow template to render partially in case it throws an exception (e.g. somewhere in the middle of the included template you have a fatal error). As you may see in both catch blocks the output buffer gets cleaned before re-throwing the initial exception.
from php-view.
2b. Actually I found a case when extract will throw an exception: when the data contains "this" key. It will result in "Fatal error: Uncaught Error: Cannot re-assign $this".
from php-view.
2a. Given that include and require are identical when the file exists, it makes no odds which is used. include
was the original author's preference.
from php-view.
- It turns out that
func_get_arg(0)
picks up the value of the first parameter at the point that it's called, not at the point it was passed into the function. See https://3v4l.org/nGGOk
We could use extract($data, EXTR_SKIP);
, which would silently ignore $data['template']
, but I think that would result in confusion compared to an explicit error.
from php-view.
Related Issues (20)
- Layout functionality HOT 1
- Rendering sub-templates? HOT 3
- Enable Travis support HOT 1
- Error trying to load javascript scripts by it src attribute HOT 5
- Layout support HOT 2
- Handling 404 errors
- PhpRenderer::render() manipulates input response HOT 1
- Return Json HOT 1
- Loop HOT 1
- Sub-templates and layouts HOT 6
- Slim 4
- Can I access the slim properties from the templates? HOT 2
- $_SESSION global variable is not available when rendering $content HOT 2
- PHP 8
- How can I include CSS in templates when using a layout HOT 4
- Switch CI from Travis to Github Actions
- Unable to flush/reset reset body when calling multiple render() HOT 2
- New Release? HOT 2
- it support javascrit ejecutions? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-view.