Skip to content

Instantly share code, notes, and snippets.

@mcfiredrill
Created August 19, 2011 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcfiredrill/1157928 to your computer and use it in GitHub Desktop.
Save mcfiredrill/1157928 to your computer and use it in GitHub Desktop.
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
@nikolas
Copy link

nikolas commented Aug 20, 2011

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment