method
safe_join
v7.1.3.2 -
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([raw("<p>foo</p>"), "<p>bar</p>"], "<br />") # => "<p>foo</p><br /><p>bar</p>" safe_join([raw("<p>foo</p>"), raw("<p>bar</p>")], raw("<br />")) # => "<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>"