Module: Releaf::Builders::Base
- Extended by:
- ActiveSupport::Concern
- Included in:
- FormBuilder, Page::HeaderBuilder, Page::LayoutBuilder, Page::MenuBuilder, PaginationBuilder, TableBuilder, ToolboxBuilder, View
- Defined in:
- app/builders/releaf/builders/base.rb
Instance Method Summary collapse
- #default_translation_scope ⇒ Object
- #html_escape(value) ⇒ Object
- #icon(name) ⇒ Object
- #layout_settings(key) ⇒ Object
- #locale_options(locales) ⇒ Object
- #resource_title(resource) ⇒ Object
- #safe_join ⇒ Object
- #t(key, options = {}) ⇒ Object
- #tag(*args) ⇒ Object
- #template_variable(variable) ⇒ Object
- #translate_locale(locale) ⇒ Object
- #wrapper(content_or_attributes_with_block, attributes = {}, &block) ⇒ Object
Instance Method Details
#default_translation_scope ⇒ Object
75 76 77 |
# File 'app/builders/releaf/builders/base.rb', line 75 def default_translation_scope controller_scope_name end |
#html_escape(value) ⇒ Object
29 30 31 |
# File 'app/builders/releaf/builders/base.rb', line 29 def html_escape(value) ERB::Util.html_escape(value) end |
#icon(name) ⇒ Object
52 53 54 |
# File 'app/builders/releaf/builders/base.rb', line 52 def icon(name) template.fa_icon(name) end |
#layout_settings(key) ⇒ Object
17 18 19 |
# File 'app/builders/releaf/builders/base.rb', line 17 def layout_settings(key) Releaf.application.config.settings_manager.read(controller: controller, key: key) end |
#locale_options(locales) ⇒ Object
69 70 71 72 73 |
# File 'app/builders/releaf/builders/base.rb', line 69 def (locales) locales.collect do|locale| [translate_locale(locale), locale] end end |
#resource_title(resource) ⇒ Object
79 80 81 |
# File 'app/builders/releaf/builders/base.rb', line 79 def resource_title(resource) Releaf::ResourceBase.title(resource) end |
#safe_join ⇒ Object
56 57 58 |
# File 'app/builders/releaf/builders/base.rb', line 56 def safe_join template.safe_join(yield) end |
#t(key, options = {}) ⇒ Object
60 61 62 63 |
# File 'app/builders/releaf/builders/base.rb', line 60 def t(key, = {}) [:scope] = default_translation_scope unless .key? :scope I18n.t(key, ) end |
#tag(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/builders/releaf/builders/base.rb', line 33 def tag(*args) return content_tag(*args) unless block_given? content_tag(*args) do block_result = yield if block_result.is_a? Array safe_join do block_result end else block_result.to_s end end end |
#template_variable(variable) ⇒ Object
48 49 50 |
# File 'app/builders/releaf/builders/base.rb', line 48 def template_variable(variable) template.instance_variable_get("@#{variable}") end |
#translate_locale(locale) ⇒ Object
65 66 67 |
# File 'app/builders/releaf/builders/base.rb', line 65 def translate_locale(locale) t(locale, scope: "locales") end |
#wrapper(content_or_attributes_with_block, attributes = {}, &block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/builders/releaf/builders/base.rb', line 21 def wrapper(content_or_attributes_with_block, attributes = {}, &block) if block_given? tag(:div, content_or_attributes_with_block, nil, nil, &block) else tag(:div, content_or_attributes_with_block, attributes) end end |