Skip to content

Commit f43271d

Browse files
committed
Document phex-rails register_output_helper :mark_safe option
1 parent 3a72bb7 commit f43271d

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

rails/helpers.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ class Components::Base < Phlex::HTML
4343
register_value_helper :format_release_date
4444

4545
# Register a Rails helper that returns safe HTML to be pushed to the output buffer.
46-
register_output_helper :pagy_nav
46+
register_output_helper :paginate
47+
48+
# If the helper returns HTML as a raw string, `:mark_safe` must be used to brand the output
49+
# as safe before it is pushed to the output buffer.
50+
register_output_helper :pagy_nav, mark_safe: true
4751
end
4852
```
4953

sgml/raw.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ raw safe(
1616

1717
In Rails, `ActiveSupport::SafeBuffer` objects are also considered safe.
1818

19-
You should avoid using `raw`. If you have to use it, you should avoid using `safe`. Most Rails gems that provide HTML will already mark it as safe if it is safe.
19+
You should avoid using `raw`. If you have to use it, you should avoid using `safe`. Most Rails gems that provide HTML will already mark it as safe if it is safe. In any case, `phlex-rails` provides a method to register helpers so that using `raw` and `safe` directly is not necessary. See [Registering custom helper adapters](../rails/helpers#registering-custom-helper-adapters).
2020

2121
When you mark a string as `safe`, you are responsible for ensuring there is no unsafe HTML user content in that string. Phlex `raw` method completely bypasses its HTML safety features when given a safe string.

0 commit comments

Comments
 (0)