Kyslik / column-sortable

Package for handling column sorting in Laravel 5/6/7/8
MIT License
644 stars 105 forks source link

Allow HTML in titles, and option to disable formatting in all custom titles #137

Closed d13r closed 4 years ago

d13r commented 4 years ago

Fixes #127, in the way I suggested in https://github.com/Kyslik/column-sortable/issues/127#issuecomment-546718374.

I split this into two commits in case you don't want the second part.

  1. Support HTML titles - for example:

    <th>@sortablelink('title', new Illuminate\Support\HtmlString('<em>Title with HTML</em>'))</th>

    This is achieved by (1) using e() instead of htmlentities(), and (2) skipping the formatting function so it's not converted to a string.

    (Tip: to shorten this to new HtmlString(...), add 'HtmlString' => Illuminate\Support\HtmlString::class to the aliases section in config.app.)

  2. A config option to not apply the formatting function to any custom titles (including regular strings).

    Personally I'd be happy for it to never apply formatting to custom titles (I can't see a good use case for doing so), but I made it a config option that defaults to true so it's fully backwards-compatible. (I could remove that if you think it's unnecessary.)

Thanks!