Class: ViewComponent::Template::Inline
- Inherits:
-
ViewComponent::Template
- Object
- ViewComponent::Template
- ViewComponent::Template::Inline
- Defined in:
- lib/view_component/template.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Attributes inherited from ViewComponent::Template
Instance Method Summary collapse
-
#initialize(component:, inline_template:) ⇒ Inline
constructor
A new instance of Inline.
- #type ⇒ Object
Methods inherited from ViewComponent::Template
#call_method_name, #compile_to_component, #coverage_running?, #default_format?, #inline_call?, #normalized_variant_name, #requires_compiled_superclass?, #safe_method_name, #safe_method_name_call
Constructor Details
#initialize(component:, inline_template:) ⇒ Inline
Returns a new instance of Inline.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/view_component/template.rb', line 76 def initialize(component:, inline_template:) details = ActionView::TemplateDetails.new(nil, inline_template.language.to_sym, nil, nil) # Rails 8.1 added a newline to compiled ERB output (rails/rails#53731). # Subtract 1 to compensate for correct line numbers in stack traces. # Inline templates start at line 2+ (defined inside a class), so this # won't result in negative line numbers that cause segfaults with coverage. lineno = if Rails::VERSION::MAJOR >= 8 && Rails::VERSION::MINOR > 0 && details.handler == :erb inline_template.lineno - 1 else inline_template.lineno end super( component: component, details: details, path: inline_template.path, lineno: lineno, ) @source = inline_template.source.dup end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
74 75 76 |
# File 'lib/view_component/template.rb', line 74 def source @source end |
Instance Method Details
#type ⇒ Object
100 101 102 |
# File 'lib/view_component/template.rb', line 100 def type :inline end |