Class: PoolParty::Template
- Defined in:
- lib/poolparty/poolparty/template.rb
Class Method Summary collapse
- .compile_file(file, opts = {}) ⇒ Object
- .compile_string(string, opts = {}) ⇒ Object
- .handle_render(string, vars, renderer) ⇒ Object
Class Method Details
.compile_file(file, opts = {}) ⇒ Object
12 13 14 15 |
# File 'lib/poolparty/poolparty/template.rb', line 12 def self.compile_file(file, opts={}) content = open(file).read compile_string(content, opts) end |
.compile_string(string, opts = {}) ⇒ Object
7 8 9 10 |
# File 'lib/poolparty/poolparty/template.rb', line 7 def self.compile_string(string, opts={}) vars = OpenStruct.new opts handle_render(string, vars, (opts.delete(:render) || :erb)) end |
.handle_render(string, vars, renderer) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/poolparty/poolparty/template.rb', line 17 def self.handle_render(string, vars, renderer) case renderer when :haml nil else ERB.new(string).result(vars.send(:binding)) end end |