Class: Flatrack::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/flatrack/template.rb,
lib/flatrack/template/rb.rb,
lib/flatrack/template/html.rb,
lib/flatrack/template/erubis.rb,
lib/flatrack/template/erubis/handler.rb

Overview

The default template parser/finder

Defined Under Namespace

Classes: Erubis, Html, Rb

Constant Summary collapse

DEFAULT_FORMAT =
'html'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, format, file) ⇒ Template

Creates a new template instance

Parameters:

  • type (Symbol)

    the type of template

  • format (String)

    the format e.g. html

  • file (String)

    the location of the file



27
28
29
30
31
# File 'lib/flatrack/template.rb', line 27

def initialize(type, format, file)
  @format      = format || DEFAULT_FORMAT
  @type, @file = type, file.to_s
  @renderer = find
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



12
13
14
# File 'lib/flatrack/template.rb', line 12

def file
  @file
end

#formatObject (readonly)

Returns the value of attribute format.



12
13
14
# File 'lib/flatrack/template.rb', line 12

def format
  @format
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/flatrack/template.rb', line 12

def type
  @type
end

Class Method Details

.find(type, format, file) ⇒ Object

Creates a new template instance and invokes find

Parameters:

  • type (Symbol)

    the type of template

  • format (String)

    the format e.g. html

  • file (String)

    the location of the file



19
20
21
# File 'lib/flatrack/template.rb', line 19

def self.find(type, format, file)
  new(type, format, file)
end