Skip to content

Conversation

@emmadesilva
Copy link
Member

@emmadesilva emmadesilva 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.)

@codecov
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.

@emmadesilva emmadesilva force-pushed the includes-facade-improvements branch from 3f49a28 to 5bcb54d Compare June 26, 2024 08:31
@emmadesilva emmadesilva force-pushed the includes-facade-improvements branch from ee9fb6a to 990a561 Compare June 26, 2024 09:14
@emmadesilva emmadesilva force-pushed the includes-facade-improvements branch from 990a561 to 45e59ce Compare June 26, 2024 09:15
@emmadesilva
Copy link
Member Author

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

Gets better IDE support and doesn't report the methods as unused
Matches the execution flow and documentation order
@emmadesilva emmadesilva marked this pull request as ready for review June 26, 2024 19:31
@emmadesilva emmadesilva merged commit ebdcb91 into 2.x-dev Jun 26, 2024
@emmadesilva emmadesilva deleted the includes-facade-improvements branch June 26, 2024 20:15
@emmadesilva emmadesilva 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.

2 participants