Module: Ore::Template

Defined in:
lib/ore/template/markup.rb,
lib/ore/template/helpers.rb,
lib/ore/template/template.rb,
lib/ore/template/directory.rb,
lib/ore/template/helpers/rdoc.rb,
lib/ore/template/interpolations.rb,
lib/ore/template/helpers/textile.rb,
lib/ore/template/helpers/markdown.rb,
lib/ore/template/exceptions/invalid_template.rb

Defined Under Namespace

Modules: Helpers, Interpolations, Markup Classes: Directory, InvalidTemplate

Class Method Summary collapse

Class Method Details

.register(path) ⇒ Symbol

Registers a template with the generator.

Parameters:

  • path (String)

    The path to the template.

Returns:

  • (Symbol)

    The name of the registered template.

Raises:

  • (StandardError)

    The given path was not a directory.

Since:

  • 0.9.0



50
51
52
53
54
55
56
57
58
59
# File 'lib/ore/template/template.rb', line 50

def self.register(path)
  unless File.directory?(path)
    raise(StandardError,"#{path.dump} is must be a directory")
  end

  name = File.basename(path).sub(/^ore-/,'').to_sym

  self.templates[name] = path
  return name
end

.template?(name) ⇒ Boolean

Determines whether a template was registered.

Parameters:

  • name (Symbol, String)

    The name of the template.

Returns:

  • (Boolean)

    Specifies whether the template was registered.

Since:

  • 0.9.0



30
31
32
# File 'lib/ore/template/template.rb', line 30

def self.template?(name)
  self.templates.has_key?(name.to_sym)
end

.templatesHash{Symbol => String}

The templates registered with the generator.

Returns:

  • (Hash{Symbol => String})

    The template names and paths.

Since:

  • 0.9.0



13
14
15
# File 'lib/ore/template/template.rb', line 13

def self.templates
  @@templates ||= {}
end