method
safe_join
v4.2.9 -
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 an HTML safe string similar to what Array#join would return. The array is flattened, and all items, 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>"