-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.6] Add Blade::include for include aliases #23172
[5.6] Add Blade::include for include aliases #23172
Conversation
How dos this behaves if I make something like Blade::include('something.include') or any other blade reserved word? |
Gonna need to dig in the compiler code for an answer on that question, I think custom directives get priority. framework/src/Illuminate/View/Compilers/BladeCompiler.php Lines 322 to 333 in ba3f3c0
Note that this question shouldn't really affect this PR, since you can already register any custom directive using a reserved word. |
If that is the case that custom directives get priority then this should not affect anything. I was thinking about some undesirable behaviour like Blade::include('something.foreach') |
Pretty cool. Would be interested to know the answer to @jmarcher's question. |
Pushed some tests that confirm that behaviour. |
Meh. Probably a bad example but I find the idea of loading micro pieces of HTML like that to be a pretty bad code smell. Just imagine it. @body
@div(['class' => 'form-group'])
@label(['text' => 'Name'])
@input(['type' =>'name'])
@enddiv
@endbody Just an idea - would it be possible "inlining" some code from view files? So this: Blade::inlineView('input', 'elements.input');
@input(['type' => 'email']) Is compiled to be inline:
|
@garygreen Push any style to the extreme and it won't be productive anymore. Regarding your second commend, I don't really see the difference between that an the includes we already have? |
I'm just thinking performance - imagine outputting hundreds of inputs on a page, each one rendering a view for that one tiny piece of HTML. Would it not make more sense to "inline" those snippets into the original compiled view, somehow? |
This does the same as #22796, but for
@include
s. Useful when you have bits of html that don't have a "slot" (self-closing parts).