Class: Plasmoid::Haml
- Inherits:
-
Object
- Object
- Plasmoid::Haml
- Defined in:
- lib/plasmoid/haml.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ Haml
constructor
A new instance of Haml.
- #valid? ⇒ Boolean
- #write ⇒ Object
Constructor Details
#initialize(path) ⇒ Haml
Returns a new instance of Haml.
5 6 7 8 9 10 11 12 |
# File 'lib/plasmoid/haml.rb', line 5 def initialize(path) @path = path @output_path = path.sub(/\.haml$/, "") if valid? ::Haml::Engine.new(File.read(@path)).def_method(self, :render) end end |
Class Method Details
Instance Method Details
#valid? ⇒ Boolean
14 15 16 |
# File 'lib/plasmoid/haml.rb', line 14 def valid? defined?(::Haml) end |
#write ⇒ Object
18 19 20 21 22 23 |
# File 'lib/plasmoid/haml.rb', line 18 def write return if !valid? File.open(@output_path, "w") do |f| f.write(self.render) end end |