Specify trim mode for the ERB compiler. Defaults to ’-’. See ERb documentation for suitable values.
# File lib/action_view/template/handlers/erb.rb, line 72 72: cattr_accessor :erb_trim_mode
# File lib/action_view/template/handlers/erb.rb, line 86 86: def compile(template) 87: if template.source.encoding_aware? 88: # First, convert to BINARY, so in case the encoding is 89: # wrong, we can still find an encoding tag 90: # (<%# encoding %>) inside the String using a regular 91: # expression 92: template_source = template.source.dup.force_encoding("BINARY") 93: 94: erb = template_source.gsub(ENCODING_TAG, '') 95: encoding = $2 96: 97: erb.force_encoding valid_encoding(template.source.dup, encoding) 98: 99: # Always make sure we return a String in the default_internal 100: erb.encode! 101: else 102: erb = template.source.dup 103: end 104: 105: self.class.erb_implementation.new( 106: erb, 107: :trim => (self.class.erb_trim_mode == "-") 108: ).src 109: end
# File lib/action_view/template/handlers/erb.rb, line 112 112: def valid_encoding(string, encoding) 113: # If a magic encoding comment was found, tag the 114: # String with this encoding. This is for a case 115: # where the original String was assumed to be, 116: # for instance, UTF-8, but a magic comment 117: # proved otherwise 118: string.force_encoding(encoding) if encoding 119: 120: # If the String is valid, return the encoding we found 121: return string.encoding if string.valid_encoding? 122: 123: # Otherwise, raise an exception 124: raise WrongEncodingError.new(string, string.encoding) 125: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.