Skip to content
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.3] Implement blade macros feature #16583

Closed
wants to merge 4 commits into from
Closed

Conversation

reshadman
Copy link

@reshadman reshadman commented Nov 29, 2016

Please see: #16525

Summary:

Using @include directive only for abstraction on large iterations(for instance a collection) causes increasing render time due to the use of native include feature. the purpose of an @include in these situations is to satisfy the Don't repeat yourself problem but it increases render time even when opcache is fully enabled. In addition to this, lots of view events are fired(creating, composing) and lots of try/catch blocks are used.

Solution:

  • Creating a new directive called @macro
  • Reading the file content of the macro from the STRING given to the @macro directive
  • Wrapping the content around a self-callable function to satisfy scoped data
  • Replacing the directive with the new generated content.

Problems:
Because of pasting the generated code inside the original view, file changes to the macro template are not detected, so views should be always cleared for each request in development environments.

@GrahamCampbell GrahamCampbell changed the title [Proposal] Implement blade macros feature. [5.3] Implement blade macros feature Nov 29, 2016
@taylorotwell
Copy link
Member

This is just quite complicated. You may be able to write it as a Blade directive to do what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants