method
safe_join
v3.2.8 -
Show latest stable
-
1 note -
Class: OutputSafetyHelper
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (29)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (-38)
- 5.1.7 (2)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
safe_join(array, sep=$,)
public
This method returns a html safe string similar to what Array#join would return. All items in the array, including the supplied separator, are html escaped unless they are html safe, and the returned string is marked as html safe.
safe_join(["<p>foo</p>".html_safe, "<p>bar</p>"], "<br />") # => "<p>foo</p><br /><p>bar</p>" safe_join(["<p>foo</p>".html_safe, "<p>bar</p>".html_safe], "<br />".html_safe) # => "<p>foo</p><br /><p>bar</p>"
Register or
log in
to add new notes.
steobrien -
April 24, 2014 - (<= v4.0.2)
2 thanks
First example's output is incorrect
Everything except the initially html_safe input should be escaped in the output.
The output of the first example should be:
# => "<p>foo</p><br /><p>bar</p>"