Class: Rad::Face::Theme
- Inherits:
-
Object
- Object
- Rad::Face::Theme
- Defined in:
- lib/face/theme.rb
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #layout_definition ⇒ Object
- #layout_template ⇒ Object
- #layout_template=(layout_template) ⇒ Object
- #name ⇒ Object
- #name=(name) ⇒ Object
Instance Attribute Details
#layout ⇒ Object
10 |
# File 'lib/face/theme.rb', line 10 def layout; @layout || 'default' end |
Class Method Details
.layout_definition(theme, layout) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/face/theme.rb', line 31 def layout_definition theme, layout path = "#{rad.face.themes_path}/#{theme}/layout_definitions/#{layout}.yml" files = Rad::Environment::FilesHelper.find_files(path, rad.template.paths) raise "multiple layout configs '#{layout}' for '#{theme}' theme!" if files.size > 1 if absolute_path = files.first YAML.load_file(absolute_path).tap do |definition| definition.must_be.a Hash definition.must.include 'layout_template' definition.must.include 'slots' definition['slots'].must_be.a Hash end else nil end end |
Instance Method Details
#layout_definition ⇒ Object
21 22 23 |
# File 'lib/face/theme.rb', line 21 def layout_definition self.class.layout_definition(name, layout) || self.class.layout_definition(name, 'default') || {} end |
#layout_template ⇒ Object
12 13 14 |
# File 'lib/face/theme.rb', line 12 def layout_template @layout_template || layout_definition['layout_template'] || 'default' end |
#layout_template=(layout_template) ⇒ Object
16 17 18 19 |
# File 'lib/face/theme.rb', line 16 def layout_template= layout_template path = "#{rad.face.themes_path}/#{name}/layout_templates/#{layout_template}" @layout_template = (layout_template and rad.template.exist?(path)) ? layout_template : 'default' end |
#name ⇒ Object
2 |
# File 'lib/face/theme.rb', line 2 def name; @name || 'default' end |
#name=(name) ⇒ Object
3 4 5 6 7 |
# File 'lib/face/theme.rb', line 3 def name= name # lots of other properties depends on :name, so we need to clean all of them if we change name clear @name = name.to_sym if name.present? end |