Module: Wallaby::View::Themeable::ClassMethods
- Defined in:
- lib/wallaby/view/themeable.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#theme ⇒ Hash
readonly
Theme metadata.
-
#theme_name ⇒ String?
readonly
Theme name.
-
#themes ⇒ Array<Hash>
readonly
A list of #theme metadata.
Instance Method Summary collapse
-
#theme_name(theme_name, **options, &block) ⇒ Object
readonly
The theme name is used to specify the layout and prefixes so that a set of theme implementation for the frontend (html/css/javascript) can be applied.
Instance Attribute Details
#theme ⇒ Hash (readonly)
Returns theme metadata.
71 72 73 74 75 76 |
# File 'lib/wallaby/view/themeable.rb', line 71 def theme defined?(@theme_name) && @theme_name && { theme_name: @theme_name, theme_path: @theme_path } || superclass.try(:theme) end |
#theme_name ⇒ String? (readonly)
Returns theme name.
53 54 55 |
# File 'lib/wallaby/view/themeable.rb', line 53 def theme_name defined?(@theme_name) && @theme_name || superclass.try(:theme_name) end |
#themes ⇒ Array<Hash> (readonly)
Returns a list of #theme metadata.
80 81 82 83 84 |
# File 'lib/wallaby/view/themeable.rb', line 80 def themes list = superclass.try(:themes) || [] list.prepend theme if defined?(@theme_name) && @theme_name list.compact end |
Instance Method Details
#theme_name=(theme_name, **options, &block) ⇒ Object (readonly)
The theme name is used to specify the layout and prefixes so that a set of theme implementation for the frontend (html/css/javascript) can be applied
When theme name is set to e.g. ‘custom_theme`, the following changes will be made:
-
layout will be set to the same name ‘custom_theme`
-
theme name will be added to the lookup prefixes right after the controller path of where it’s defined.
Once theme name is set, all its subclass controllers will inherit the same theme name
45 46 47 48 49 |
# File 'lib/wallaby/view/themeable.rb', line 45 def theme_name=(theme_name, **, &block) layout theme_name, , &block @theme_path = theme_name && controller_path || nil @theme_name = theme_name || nil end |