Class: Magneto::Template

Inherits:
Object
  • Object
show all
Includes:
Readable
Defined in:
lib/magneto/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Readable

#content, #content=, #content?, #metadata, #metadata=, #metadata?, #read

Constructor Details

#initialize(site, path, name) ⇒ Template

Returns a new instance of Template.



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

def initialize(site, path, name)
  super()
  @site = site
  @path = path
  @name = name
  @filter = nil
  @metadata = nil
  @content = nil
end

Instance Attribute Details

#filterObject (readonly)

Returns the value of attribute filter.



6
7
8
# File 'lib/magneto/template.rb', line 6

def filter
  @filter
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/magneto/template.rb', line 6

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/magneto/template.rb', line 6

def path
  @path
end

#siteObject (readonly)

Returns the value of attribute site.



6
7
8
# File 'lib/magneto/template.rb', line 6

def site
  @site
end

Instance Method Details

#import_metadataObject



27
28
29
# File 'lib/magneto/template.rb', line 27

def 
  @filter = use_filter(@metadata[:filter]) unless @metadata.nil? || @metadata[:filter].nil?
end

#use_filter(filter_name) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/magneto/template.rb', line 18

def use_filter(filter_name)
  @filter = @site.filters[filter_name.to_sym]

  if @filter.nil?
    $stderr.puts "#{File.basename($PROGRAM_NAME)}: #{ex.to_s}"
    raise "Couldn't find filter: '#{filter_name.to_s}'"
  end
end