Module: Mint::Template

Defined in:
lib/mint/template.rb

Class Method Summary collapse

Class Method Details

.find_directory_by_name(name) ⇒ Pathname

Finds a template directory by name

Parameters:

  • name (String)

    the template name to find

Returns:

  • (Pathname)

    path to the template directory



23
24
25
26
27
28
# File 'lib/mint/template.rb', line 23

def self.find_directory_by_name(name)
  Mint::PATH.
    map {|p| p + Mint::TEMPLATES_DIRECTORY + name }.
    select(&:exist?).
    first
end

.valid?(directory) ⇒ Boolean

Indicates whether the directory is a valid template directory.

Parameters:

  • directory (Pathname)

    the directory to check

Returns:

  • (Boolean)

    true if the directory is a valid template directory



9
10
11
12
13
14
15
16
17
# File 'lib/mint/template.rb', line 9

def self.valid?(directory)
  # Note that typically templates have only a stylesheet, although they can
  # optionally include a layout file. Most templates can get by with the layout
  # provided by the default template, which is automatically used if no layout
  # file is provided in the template directory.
  directory.children.
    select(&:file?).
    select(&Style.method(:valid?))
end