Skip to content

Instantly share code, notes, and snippets.

@nashby

nashby/safe.rb

Created Mar 21, 2012
Embed
What would you like to do?
attribute_names.map do |attribute_name|
attribute(attribute_name)
end.join.html_safe
# vs.
"".html_safe.tap do |attributes|
attribute_names.each do |attribute_name|
attributes.safe_concat attribute(attribute_name)
end
end
# vs
@template.safe_join(attribute_names.map do |attribute_name|
attribute(attribute_name)
end)
# vs
attribute_names.map do |attribute_name|
attribute(attribute_name)
end.inject(:safe_concat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment