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