Created
July 31, 2011 01:40
-
-
Save ajsharp/1116248 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def compile_template_method(locals) | |
| source, offset = precompiled(locals) | |
| offset += 5 | |
| method_name = "__tilt_#{Thread.current.object_id.abs}" | |
| Object.class_eval <<-RUBY, eval_file, line - offset | |
| #{extract_magic_comment source} | |
| TOPOBJECT.class_eval do | |
| def #{method_name}(locals) | |
| Thread.current[:tilt_vars] = [self, locals] | |
| class << self | |
| this, locals = Thread.current[:tilt_vars] | |
| this.instance_eval do | |
| #{source} | |
| end | |
| end | |
| end | |
| end | |
| RUBY | |
| unbind_compiled_method(method_name) | |
| end | |
| def unbind_compiled_method(method_name) | |
| method = TOPOBJECT.instance_method(method_name) | |
| TOPOBJECT.class_eval { remove_method(method_name) } | |
| method | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment