Class: Schoolkeep::Views::Layout
- Inherits:
-
Object
- Object
- Schoolkeep::Views::Layout
- Defined in:
- lib/schoolkeep/views/layout.rb
Constant Summary collapse
- BODY_CLASSES =
{ "course_details.html.sktl" => "school_website-courses school_website-courses-show", "course_index.html.sktl" => "school_website-courses school_website-courses-index", "custom_page.html.sktl" => "school_website-custom_pages school_website-custom_pages-show", "homepage.html.sktl" => "school_website-homepages school_website-homepages-show", "my_content.html.sktl" => "school_website-my_content school_website-my_content-index" }
- LAYOUTS =
Hash.new("school_website")
Class Attribute Summary collapse
-
.asset_host ⇒ Object
Returns the value of attribute asset_host.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Class Method Summary collapse
Instance Method Summary collapse
- #asset_url(path) ⇒ Object
- #body_classes ⇒ Object
- #current_school ⇒ Object
-
#initialize(template) ⇒ Layout
constructor
A new instance of Layout.
- #preview_banner ⇒ Object
- #render(variables: {}) ⇒ Object
- #render_skt(partial_name, variables: {}) ⇒ Object
Constructor Details
Class Attribute Details
.asset_host ⇒ Object
Returns the value of attribute asset_host.
11 12 13 |
# File 'lib/schoolkeep/views/layout.rb', line 11 def asset_host @asset_host end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
29 30 31 |
# File 'lib/schoolkeep/views/layout.rb', line 29 def body @body end |
Class Method Details
.asset_cache ⇒ Object
13 14 15 |
# File 'lib/schoolkeep/views/layout.rb', line 13 def asset_cache @asset_cache ||= AssetCache.new(asset_host) end |
Instance Method Details
#asset_url(path) ⇒ Object
40 41 42 |
# File 'lib/schoolkeep/views/layout.rb', line 40 def asset_url(path) self.class.asset_cache[path] end |
#body_classes ⇒ Object
36 37 38 |
# File 'lib/schoolkeep/views/layout.rb', line 36 def body_classes BODY_CLASSES[@template.name] end |
#current_school ⇒ Object
44 45 46 |
# File 'lib/schoolkeep/views/layout.rb', line 44 def current_school @school end |
#preview_banner ⇒ Object
48 49 50 |
# File 'lib/schoolkeep/views/layout.rb', line 48 def @preview_banner end |
#render(variables: {}) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/schoolkeep/views/layout.rb', line 57 def render(variables: {}) @body = @template.render(variables: variables) layout_path = File.join(GEM_ROOT, "config/#{LAYOUTS[@template.name]}.html.erb") layout= File.read(layout_path) set_context_variables_for_layout ERB.new(layout).result(binding) end |