Skip to content

Instantly share code, notes, and snippets.

@plexus
Created October 20, 2014 10:39
Show Gist options
  • Save plexus/70b9cd47978f947682e1 to your computer and use it in GitHub Desktop.
Save plexus/70b9cd47978f947682e1 to your computer and use it in GitHub Desktop.
module Hexp
# Transparently use Hexp nodes in templates
class Node
def to_s
to_html.html_safe
end
end
# Honor ActiveSupport::SafeBuffer's "html_safe" flag
class Unparser
alias orig_escape_text escape_text
def escape_text(text)
text.html_safe? ? text : orig_escape_text(text)
end
end
end
# Opt-in to NilClass#to_hexp
require 'hexp/core_ext/nil'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment