diff --git a/lib/view_component/compiler.rb b/lib/view_component/compiler.rb index 6aa13617c..1cc258dff 100644 --- a/lib/view_component/compiler.rb +++ b/lib/view_component/compiler.rb @@ -55,7 +55,7 @@ def call SOURCE # rubocop:disable Style/EvalWithLocation if frozen_string_literal - component_class.class_eval("# frozen_string_literal: true\n#{source}", template.path, template.lineno - 1) + component_class.class_eval(source.prepend("# frozen_string_literal: true\n"), template.path, template.lineno - 1) else component_class.class_eval(source, template.path, template.lineno) end @@ -83,7 +83,7 @@ def #{method_name} SOURCE # rubocop:disable Style/EvalWithLocation if frozen_string_literal - component_class.class_eval("# frozen_string_literal: true\n#{source}", template[:path], -1) + component_class.class_eval(source.prepend("# frozen_string_literal: true\n"), template[:path], -1) else component_class.class_eval(source, template[:path], 0) end