ViewComponent/view_component · error · ViewComponent::TemplateError
TEMPLATE_ERRORS
Error message
TEMPLATE_ERRORS
What it means
Error "TEMPLATE_ERRORS" thrown in ViewComponent/view_component.
Source
Thrown at lib/view_component/compiler.rb:38
end
def compile(raise_errors: false, force: false)
return if compiled? && !force
return if @component == ViewComponent::Base
@lock.synchronize do
# this check is duplicated so that concurrent compile calls can still
# early exit
return if compiled? && !force
gather_templates
if self.class.__vc_development_mode && @templates.any?(&:requires_compiled_superclass?)
@component.superclass.__vc_compile(raise_errors: raise_errors)
end
if template_errors.present?
raise TemplateError.new(template_errors) if raise_errors
# this return is load bearing, and prevents the component from being considered "compiled?"
return false
end
if raise_errors
@component.__vc_validate_initialization_parameters!
@component.__vc_validate_collection_parameter!
end
define_render_template_for
@component.__vc_register_default_slots
@component.__vc_build_i18n_backend
CompileCache.register(@component)
@component.after_compileView on GitHub (pinned to 9f22c36fa7)
Solutions
- Provide a template: create a sidecar template file (e.g. my_component.html.erb) next to the component class, or define an inline `call` method or `erb_template` in the component.
- Resolve duplicate templates: the component must not define multiple templates for the same variants/formats, nor both an inline template and a sidecar template.
- Fix any template syntax errors reported in the error detail.
When it happens
Trigger: Thrown at lib/view_component/compiler.rb:38 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ViewComponent/view_component@9f22c36fa7 (2026-08-23).
Data as JSON: /api/errors/726a5d4d72e75d18.
Report an issue: GitHub.