-
Notifications
You must be signed in to change notification settings - Fork 180
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
V4 Block Func #175
Comments
Would very much like other opinions on this one to see what the community would prefer. |
@velosipedist @gmazzap What do you think about this syntax? |
I'm leaning towards the if block syntax. |
- Added more tests - Removed the compose func since it's not used Signed-off-by: RJ Garcia <[email protected]>
Not that it carry's much weight but my personal opinion is that the if block syntax makes sense; however I do read |
Hmm, interesting point. maybe I was trying to save on characters, and i was worried people would omit the But i'm not sold on either way. Just need feedback from the community to see what makes the most sense. |
If use the block/end syntax, there would be no ambiguity like you mention; however, we'd have to needlessly process everything in the if block. |
Maybe we could come up with a way that everything between |
- Added ability for else parts in sections - It supports stringables and closures for lazy evaluation Signed-off-by: RJ Garcia <[email protected]>
- Added ability for else parts in sections - It supports stringables and closures for lazy evaluation - Created obWrap utility to wrap a closure and error handling with output buffering Signed-off-by: RJ Garcia <[email protected]>
I ended up going with just a second parameter to the section func instead of adding a new one. I felt like it was confusing to have two functions that do the same thing, and the if statement part was a little weird. The new syntax allows a closure to be passed in as the second parameter which is lazily evaluated. <?=$v->section('meta', function() { ?>
<meta charset="UTF-8"/>
<?php }); ?> |
Add a block func that will allow the following semantics:
If the section exists, it should echo the section content and discard the content from the
end
callback. If it does not exist, it should output the contents from theend
callback.This maybe depends on #177
A different alternative is to use an if statement. This is more verbose, but allows us to not even buffer the default content if we don't want to.
In this scenario, the block func simply echos the section content and returns false it exists, or just returns true.
The text was updated successfully, but these errors were encountered: