Class: Ruty::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/ruty/loaders.rb

Overview

base class for all loaders

Direct Known Subclasses

Ruty::Loaders::Filesystem

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ Loader

Returns a new instance of Loader.



15
16
17
18
19
20
# File 'lib/ruty/loaders.rb', line 15

def initialize options=nil
  if not options.nil? and not options.is_a?(Hash)
    raise ArgumentError, 'loader options must be a hash or omitted'
  end
  @options = options or {}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



13
14
15
# File 'lib/ruty/loaders.rb', line 13

def options
  @options
end

Instance Method Details

#get_template(name) ⇒ Object

method for loading templates in an application. Returns a template instance with the loaded name.



40
41
42
# File 'lib/ruty/loaders.rb', line 40

def get_template name
  Template.new(load_cached(name))
end

#load_cached(name, parent = nil) ⇒ Object

load a template, probably from cache Per default this calls the load_local method with the same paramters



25
26
27
# File 'lib/ruty/loaders.rb', line 25

def load_cached name, parent=nil
  load_local(name, parent)
end

#load_local(name, parent = nil) ⇒ Object

load a template by always reparsing it. That for example is used by the inheritance and inclusion system because the tags modify the nodelist returned by a loader. If parent is given it must be used to resolve relative paths

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/ruty/loaders.rb', line 34

def load_local name, parent=nil
  raise NotImplementedError
end