framework icon indicating copy to clipboard operation
framework copied to clipboard

[11.x] Switch Js::encode() to return HtmlString

Open valorin opened this issue 1 year ago • 1 comments

Updating the Js::encode() helper to return an instance of HtmlString rather than a raw string.

The primary reason is to support using the normal escaping Blade tags: {{ Js::encode() }}, rather than {!! Js::encode() !}}, when using this in Blade. This will then match the behaviour already possible with Js::from() which returns an instance of Htmlable and supports {{ Js::from() }}.

Since this is a breaking change, it will need to go into v11 - hence the master branch.

There are no downsides to this change, it may just require minor code updates - which should be trivial to identify and perform with a search for Js::encode(.

valorin avatar Jan 10 '24 20:01 valorin

Thanks. Paging in @calebporzio to see if this affects Livewire.

driesvints avatar Jan 11 '24 09:01 driesvints

@calebporzio took a Quick Look at this one but didn't see anything wrong with it at first sight. So marking this as ready for review again.

driesvints avatar Mar 12 '24 08:03 driesvints

Didn't quite get to this before L11 release.

taylorotwell avatar Mar 12 '24 18:03 taylorotwell

@taylorotwell does that mean this'll need to wait for Laravel 12?

Can we apply this to master now so it doesn't get forgotten again?

valorin avatar Mar 12 '24 21:03 valorin

Best to just attempt a PR @valorin

driesvints avatar Mar 12 '24 21:03 driesvints