Module: Mint::Layout
- Defined in:
- lib/mint/layout.rb
Constant Summary collapse
- HTML_EXTENSIONS =
["html", "erb"]
Class Method Summary collapse
-
.find_by_name(name) ⇒ Pathname
Returns the layout file for the given template name.
-
.find_in_directory(directory) ⇒ Pathname
Finds the layout file in a specific directory.
-
.valid?(pathname) ⇒ Boolean
Indicates whether the file is a valid layout file.
Class Method Details
.find_by_name(name) ⇒ Pathname
Returns the layout file for the given template name
19 20 21 |
# File 'lib/mint/layout.rb', line 19 def self.find_by_name(name) find_in_directory Template.find_directory_by_name(name) end |
.find_in_directory(directory) ⇒ Pathname
Finds the layout file in a specific directory
27 28 29 |
# File 'lib/mint/layout.rb', line 27 def self.find_in_directory(directory) directory&.children&.select(&:file?)&.select(&method(:valid?))&.first end |
.valid?(pathname) ⇒ Boolean
Indicates whether the file is a valid layout file
11 12 13 |
# File 'lib/mint/layout.rb', line 11 def self.valid?(pathname) HTML_EXTENSIONS.map {|ext| "layout.#{ext}" }.include? pathname.basename.to_s end |