Class: Storefront::Components::Form::Hint
- Defined in:
- lib/storefront/components/form/hint.rb
Constant Summary
Constants included from Helpers::ContentHelper
Helpers::ContentHelper::SCOPES, Helpers::ContentHelper::SCOPES_WITH_NAMESPACE, Helpers::ContentHelper::SCOPES_WITH_NAMESPACE_AND_NESTED_MODEL, Helpers::ContentHelper::SCOPES_WITH_NESTED_MODEL
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Hint
constructor
A new instance of Hint.
- #render(&block) ⇒ Object
Methods included from Helpers::DomHelper
#aria, #clone_attributes, #dom, #index_class, #merge_class, #merge_class!, #page, #resource_to_title, #title_widget, #title_widget_options
Methods included from Helpers::ContentHelper
#encoded_contents, #font_face_data_uri, #html5_time, #read_binary_file, #read_image_size, #rendered_text, #sanitize, #t?
Methods inherited from Base
#component_name, #extract_classes!, #extract_options!, #inside?, #pointer, #render_with_pointer, #to_s
Constructor Details
#initialize(options = {}) ⇒ Hint
Returns a new instance of Hint.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/storefront/components/form/hint.rb', line 5 def initialize( = {}) super attributes.merge!([:hint_html]) if [:hint_html] attributes.delete :hint_html attributes.delete :hint unless [:hint] == false merge_class! attributes, config.hint_class attributes[:id] ||= attribute.to_id(:type => :hint, :index => index, :parent_index => parent_index) if config.id_enabled_on.include?("hint") if config.include_aria && config.hint_is_popup attributes[:role] ||= :tooltip end @value = localize(:hints, attribute.name, [:hint].is_a?(::String) ? [:hint] : nil, :allow_blank => true) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Storefront::Components::Base
Instance Method Details
#render(&block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/storefront/components/form/hint.rb', line 22 def render(&block) template.capture_haml do if value.present? template.haml_tag config.hint_tag, attributes do template.haml_concat value.html_safe.gsub(/\n$/, "") end elsif config.always_include_hint_tag template.haml_tag config.hint_tag, attributes end end end |