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

[2.x] Includes facade improvements #1738

Merged
merged 105 commits into from
Jun 26, 2024
Merged

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva commented Jun 26, 2024

  • Methods in the Includes facade now return HtmlString objects instead of string
  • Markdown includes are now converted to HTML using the custom HydePHP Markdown service, meaning they now support full GFM spec and custom Hyde features like colored blockquotes and code block filepath labels
  • Markdown returned from includes are now trimmed of trailing whitespace and newlines
  • The Includes::path() and Includes::get() methods now normalizes paths to be basenames to match the behaviour of the other include method.
    • This means that nested directories are no longer supported, as you should use a data collection for that.

Includes facade changes

The following methods in the Includes facade now return HtmlString objects instead of string:

  • Includes::html()
  • Includes::blade()
  • Includes::markdown()

Notes:

  • This means that you no longer need to use {!! !!} to render the output of these methods in Blade templates, instead just use {{ }}.
  • If you have used the return value of these methods in custom code, you may need to adjust your code to work with the new return type.

For more information, see the RFC that proposed this change: #1734
The RFC was implemented in #1738

Remember to escape output if necessary

Note: Remember that this means that includes are no longer escaped by default, so make sure to escape the output if necessary, for example if the content is user-generated.

  • (Use {{ e(Includes::html('foo')) }} instead of {{ Includes::html('foo') }} to escape the output, matching the previous behavior.)

Copy link

codecov bot commented Jun 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.95%. Comparing base (8de4d37) to head (befd302).

Additional details and impacted files
@@            Coverage Diff             @@
##             2.x-dev    #1738   +/-   ##
==========================================
  Coverage      99.95%   99.95%           
- Complexity      1806     1810    +4     
==========================================
  Files            185      185           
  Lines           4786     4793    +7     
==========================================
+ Hits            4784     4791    +7     
  Misses             2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@caendesilva
Copy link
Member Author

Could we hook into the Blade @include directive? (And should we?)

@caendesilva caendesilva marked this pull request as ready for review June 26, 2024 19:31
@caendesilva caendesilva merged commit ebdcb91 into 2.x-dev Jun 26, 2024
9 checks passed
@caendesilva caendesilva deleted the includes-facade-improvements branch June 26, 2024 20:15
@caendesilva caendesilva added this to the v2 milestone Jul 9, 2024
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.

1 participant