Created
August 19, 2011 20:31
-
-
Save mcfiredrill/1157928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'haml' | |
@template = File.read(ARGV[0]) | |
@engine = Haml::Engine.new(@template) | |
@template_scope = Object.new | |
@partials = {} | |
Dir.glob("./src/_*.haml").each do |f| | |
partial_name = f.sub(/_/, '') | |
partial_name.sub!(/\.haml/, '') | |
@partials["#{partial_name}"] = File.read(f) | |
end | |
def myrender(partial, locals = {}) | |
partial_engine = Haml::Engine.new(@partials[partial]) | |
partial_output = partial_engine.render(scope = @template_scope, locals) | |
@template_scope.instance_variable_get("@haml_buffer").buffer << output | |
end | |
def output | |
out = @engine.render(scope=@template_scope) | |
puts out | |
end | |
output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
...