Class: Slippers::TemplateGroupDirectory
- Inherits:
-
TemplateGroup
- Object
- TemplateGroup
- Slippers::TemplateGroupDirectory
- Defined in:
- lib/engine/template_group_directory.rb
Instance Attribute Summary collapse
-
#default_string ⇒ Object
readonly
Returns the value of attribute default_string.
-
#directory_paths ⇒ Object
readonly
Returns the value of attribute directory_paths.
-
#missing_handler ⇒ Object
readonly
Returns the value of attribute missing_handler.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #find(subtemplate) ⇒ Object
- #has_registered?(class_name) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(directory_paths, params = {}) ⇒ TemplateGroupDirectory
constructor
A new instance of TemplateGroupDirectory.
- #render(item) ⇒ Object
Constructor Details
#initialize(directory_paths, params = {}) ⇒ TemplateGroupDirectory
Returns a new instance of TemplateGroupDirectory.
3 4 5 6 7 8 |
# File 'lib/engine/template_group_directory.rb', line 3 def initialize(directory_paths, params={}) @directory_paths = directory_paths @super_group = params[:super_group] @missing_handler = params[:missing_template_handler] || Slippers::Engine::MISSING_HANDLER @default_string = params[:default_string] || Slippers::Engine::DEFAULT_STRING end |
Instance Attribute Details
#default_string ⇒ Object (readonly)
Returns the value of attribute default_string.
10 11 12 |
# File 'lib/engine/template_group_directory.rb', line 10 def default_string @default_string end |
#directory_paths ⇒ Object (readonly)
Returns the value of attribute directory_paths.
10 11 12 |
# File 'lib/engine/template_group_directory.rb', line 10 def directory_paths @directory_paths end |
#missing_handler ⇒ Object (readonly)
Returns the value of attribute missing_handler.
10 11 12 |
# File 'lib/engine/template_group_directory.rb', line 10 def missing_handler @missing_handler end |
Instance Method Details
#eql?(other) ⇒ Boolean
29 30 31 32 |
# File 'lib/engine/template_group_directory.rb', line 29 def eql?(other) return false unless other directory_paths.eql?(other.directory_paths) end |
#find(subtemplate) ⇒ Object
12 13 14 15 16 |
# File 'lib/engine/template_group_directory.rb', line 12 def find(subtemplate) file_name = @directory_paths.map { |directory_path| directory_path + '/' + subtemplate + '.st' }.find { |f| File.exist? f} return Engine.new(FileTemplate.new(file_name).template, :template_group => self) if file_name find_renderer_or_supergroup(subtemplate) end |
#has_registered?(class_name) ⇒ Boolean
18 19 20 21 |
# File 'lib/engine/template_group_directory.rb', line 18 def has_registered?(class_name) return false unless @super_group @super_group.has_registered?(class_name) end |
#hash ⇒ Object
33 34 35 |
# File 'lib/engine/template_group_directory.rb', line 33 def hash @directory_paths.hash end |
#render(item) ⇒ Object
23 24 25 26 |
# File 'lib/engine/template_group_directory.rb', line 23 def render(item) return '' unless @super_group @super_group.render(item) end |