method
compiled_source
v8.1.1 -
Show latest stable
- Class:
ActionView::Template
compiled_source()public
This method compiles the source of the template. The compilation of templates involves setting strict_locals! if applicable, encoding the template, and setting frozen string literal.
# File actionview/lib/action_view/template.rb, line 443
def compiled_source
set_strict_locals = strict_locals!
source = encode!
code = @handler.call(self, source)
method_arguments =
if set_strict_locals
if set_strict_locals.include?("&")
"local_assigns, output_buffer, #{set_strict_locals}"
else
"local_assigns, output_buffer, #{set_strict_locals}, &_"
end
else
"local_assigns, output_buffer, &_"
end
# Make sure that the resulting String to be eval'd is in the
# encoding of the code
source = + def #{method_name}(#{method_arguments}) @virtual_path = #{@virtual_path.inspect};#{locals_code};#{code} end
# Make sure the source is in the encoding of the returned code
source.force_encoding(code.encoding)
# In case we get back a String from a handler that is not in
# BINARY or the default_internal, encode it to the default_internal
source.encode!
# Now, validate that the source we got back from the template
# handler is valid in the default_internal. This is for handlers
# that handle encoding but screw up
unless source.valid_encoding?
raise WrongEncodingError.new(source, Encoding.default_internal)
end
if Template.frozen_string_literal
"# frozen_string_literal: true\n#{source}"
else
source
end
end Related methods
- Instance methods
- compile
- compile!
- compiled_source
- encode!
- find_node_by_id
- handle_render_error
- identifier_method_name
- inspect
- instrument
- instrument_payload
- instrument_render_template
- local_assigns
- locals
- locals_code
- marshal_dump
- marshal_load
- method_name
- offset
- render
- short_identifier
- source
- spot
- strict_locals!
- strict_locals?
- supports_streaming?
- translate_location
- type
- Class methods
- mime_types_implementation=
- new