Skip to content

[6.x] Blade parity#19148

Open
riasvdv wants to merge 13 commits into
6.xfrom
feature/blade-parity
Open

[6.x] Blade parity#19148
riasvdv wants to merge 13 commits into
6.xfrom
feature/blade-parity

Conversation

@riasvdv

@riasvdv riasvdv commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Description

Adds initial Blade directives and an engine-agnostic renderer for Craft templates which brings near-parity for Blade templates

See docs/blade.md

Of course we can add more in the future or upon request

@riasvdv riasvdv marked this pull request as ready for review June 22, 2026 16:36
Comment thread src/View/TemplateRenderer.php Outdated
Comment thread src/View/TemplateRenderer.php Outdated
Comment on lines +80 to +83
private function isBlade(string $path): bool
{
return Str::endsWith($path, '.blade.php');
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this the responsibility of the renderer or engine, instead? Something like…

  • Resolve template path
  • Define list of renderers
  • Emit event so plugins can add new ones
  • Call (e.g.) RendererInterface::matchPath() on each one, returning the first one that says it can render the provided path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this suggestion! I've refactored into an interface now with a BaseTemplateRenderer which does a lot of the ceremony, the BladeRenderer is just a small implementation of that now. In theory other renderers could also be added.

Comment thread src/Twig/Extensions/LaravelExtension.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort of off-topic, but this is a cool refactor from RequireEdition!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I noticed there were a lot of try-catches around it with the same 404 if debug mode is disabled, so this nicely consolidates it

There's probably some other places we could use this

Comment thread src/View/ViewServiceProvider.php Outdated
Comment thread docs/blade.md
Comment thread docs/blade.md
@riasvdv riasvdv force-pushed the feature/blade-parity branch from d17bad6 to 3efc354 Compare June 23, 2026 08:58
@riasvdv riasvdv requested a review from AugustMiller June 23, 2026 09:08
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.

2 participants