Sha256: 6f1fd16dc036dabac1c6a850c33d17e6a7bfb1ee374afdede796dafe4ebd615d

Contents?: true

Size: 997 Bytes

Versions: 70

Compression:

Stored size: 997 Bytes

Contents

# We use Hash#inspect in ExpressTemplates::Markup::Wrapper to reproduce arguments
# to helpers in the Rails view.
#
# Hash#inspect calls #inspect on values and keys.  This allows us to
# place the resulting string into the view code with a simple substitution
# or concatenation.
#
# In special cases, however, we might want the argument or one of its keys
# or values to be the result of evaluating of a ruby expression in the view
# that does not itself return a String.  The result of #inspect
# is normally a quoted and escaped string which would evaluate to a string
# in the view.  What we want is a simple string of code.  Here we provide
# a method that overrides #inspect in the strings eigenclass to strip off
# enclosing quotes or unwanted escapes.  It shouldn't bother anybody and
# it keeps us from doing messy things elsewhere for now.
class String
  def to_view_code
    class << self
      def inspect
        super.gsub(/^"(.*)"$/,'\1')
      end
    end
    return self
  end
end

Version data entries

70 entries across 70 versions & 2 rubygems

Version Path
express_templates-0.11.20 lib/core_extensions/string.rb
express_templates-0.11.20.rc1 lib/core_extensions/string.rb
express_templates-0.11.19 lib/core_extensions/string.rb
express_templates-0.11.18 lib/core_extensions/string.rb
express_templates-0.11.17 lib/core_extensions/string.rb
express_templates-0.11.16 lib/core_extensions/string.rb
express_templates-0.11.16.rc1 lib/core_extensions/string.rb
express_templates-0.11.15 lib/core_extensions/string.rb
express_templates-0.11.14 lib/core_extensions/string.rb
express_templates-0.11.13 lib/core_extensions/string.rb
express_templates-0.11.11 lib/core_extensions/string.rb
express_templates-0.11.10 lib/core_extensions/string.rb
express_templates-0.11.9 lib/core_extensions/string.rb
express_templates-0.11.8 lib/core_extensions/string.rb
express_templates-0.11.7 lib/core_extensions/string.rb
express_templates-0.11.6 lib/core_extensions/string.rb
express_templates-0.11.5 lib/core_extensions/string.rb
express_templates-0.11.4 lib/core_extensions/string.rb
express_admin-1.7.5 vendor/gems/express_templates/lib/core_extensions/string.rb
express_admin-1.7.4 vendor/gems/express_templates/express_templates/lib/core_extensions/string.rb