Class: Skytap::Templates::Base
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Skytap::Templates::Base
- Defined in:
- lib/skytap/templates.rb
Direct Known Subclasses
Class Method Summary collapse
-
.render(hash) ⇒ Object
The template can refer to hash keys as if they were local variables.
Instance Method Summary collapse
Class Method Details
.render(hash) ⇒ Object
The template can refer to hash keys as if they were local variables.
26 27 28 29 |
# File 'lib/skytap/templates.rb', line 26 def self.render(hash) attrs = {'description' => 'DEFAULT DESCRIPTION HERE'}.merge(hash) new(attrs).render end |
Instance Method Details
#indent(msg = '', width = 5) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/skytap/templates.rb', line 41 def indent(msg='', width=5) msg ||= '' msg.split("\n").collect do |line| (' ' * width) << line end.join("\n") end |
#render ⇒ Object
35 36 37 38 39 |
# File 'lib/skytap/templates.rb', line 35 def render # Allow -%> to trim surrounding whitespace in ERB. trim_mode_char = '-' ERB.new(template_str, nil, trim_mode_char).result(binding) end |
#template_str ⇒ Object
31 32 33 |
# File 'lib/skytap/templates.rb', line 31 def template_str raise 'must be overridden' end |