lib/primer/forms/base.rb in primer_view_components-0.0.108 vs lib/primer/forms/base.rb in primer_view_components-0.0.109
- old
+ new
@@ -42,17 +42,21 @@
base.fields_with_caption_templates << File.basename(path).chomp("_caption.html.erb").to_sym
end
end
def caption_template?(field_name)
- fields_with_caption_templates.include?(field_name)
+ fields_with_caption_templates.include?(sanitize_field_name_for_template_path(field_name))
end
def fields_with_caption_templates
@fields_with_caption_templates ||= []
end
+ def sanitize_field_name_for_template_path(field_name)
+ field_name.to_s.delete_suffix("?").to_sym
+ end
+
private
# Unfortunately this bug (https://github.com/ruby/ruby/pull/5646) prevents us from using
# Ruby's native Module.const_source_location. Instead we have to fudge it by searching
# for the file in the configured autoload paths. Doing so relies on Rails' autoloading
@@ -113,11 +117,11 @@
def after_content?(*args)
self.class.after_content?(*args)
end
- def render_caption_template(name)
- send(:"render_#{name}_caption")
+ def render_caption_template(field_name)
+ send(:"render_#{self.class.sanitize_field_name_for_template_path(field_name)}_caption")
end
def perform_render(&_block)
Base.compile!
self.class.compile!