Object
# File lib/action_view/template/handlers/erb.rb, line 65 65: def call(template) 66: if template.source.encoding_aware? 67: # First, convert to BINARY, so in case the encoding is 68: # wrong, we can still find an encoding tag 69: # (<%# encoding %>) inside the String using a regular 70: # expression 71: template_source = template.source.dup.force_encoding("BINARY") 72: 73: erb = template_source.gsub(ENCODING_TAG, '') 74: encoding = $2 75: 76: erb.force_encoding valid_encoding(template.source.dup, encoding) 77: 78: # Always make sure we return a String in the default_internal 79: erb.encode! 80: else 81: erb = template.source.dup 82: end 83: 84: self.class.erb_implementation.new( 85: erb, 86: :trim => (self.class.erb_trim_mode == "-") 87: ).src 88: end
# File lib/action_view/template/handlers/erb.rb, line 92 92: def valid_encoding(string, encoding) 93: # If a magic encoding comment was found, tag the 94: # String with this encoding. This is for a case 95: # where the original String was assumed to be, 96: # for instance, UTF-8, but a magic comment 97: # proved otherwise 98: string.force_encoding(encoding) if encoding 99: 100: # If the String is valid, return the encoding we found 101: return string.encoding if string.valid_encoding? 102: 103: # Otherwise, raise an exception 104: raise WrongEncodingError.new(string, string.encoding) 105: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.