Class: Flatrack::Template
- Inherits:
-
Object
- Object
- Flatrack::Template
- 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
Constant Summary collapse
- DEFAULT_FORMAT =
'html'
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.find(base_path, type, format, file) ⇒ Object
Creates a new template instance and invokes find.
- .register_path(path) ⇒ Object
Instance Method Summary collapse
-
#initialize(base_path, type, format, file) ⇒ Template
constructor
Creates a new template instance.
Constructor Details
#initialize(base_path, type, format, file) ⇒ Template
Creates a new template instance
34 35 36 37 38 39 |
# File 'lib/flatrack/template.rb', line 34 def initialize(base_path, type, format, file) @base_path = base_path @format = format || DEFAULT_FORMAT @type, @file = type, file.to_s @renderer = find end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
12 13 14 |
# File 'lib/flatrack/template.rb', line 12 def base_path @base_path end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
12 13 14 |
# File 'lib/flatrack/template.rb', line 12 def file @file end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
12 13 14 |
# File 'lib/flatrack/template.rb', line 12 def format @format end |
#type ⇒ Object (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(base_path, type, format, file) ⇒ Object
Creates a new template instance and invokes find
26 27 28 |
# File 'lib/flatrack/template.rb', line 26 def self.find(base_path, type, format, file) new(base_path, type, format, file) end |
.register_path(path) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/flatrack/template.rb', line 15 def self.register_path(path) classes.each do |klass| files = Dir.glob File.join path, '**', "*.#{klass::RENDERS}" Tilt.register klass, *files end end |