Posted By: Brad Phelan
Date: 2006-09-13 08:10
Summary: Galena goes alpha
Project: Galena
I'm proud to present Galena version 0.0.1.
Galena is an object oriented templating extension to Ruby that does not rely on eval and bindings duringthe normal execution of the template code. It uses meta-programming techniques to add new methods to a class. Templated methods can be defined inline in a normal Ruby file.
A quick example.
class Foo
tdef :bar, "food" <<-END
eat %=food=%
END
end
foo = Foo.new
puts foo.bar "curry"
eat curry
A bigger and badder example can be found at
http://galena.rubyforge.org/classes/Galena.html
Apart from templates becoming proper methods, the templates also allow nesting. Templates can use yield and accept blocks. The example in the above link shows how this concept is used. Effectively it means the concept of layouts can be used at any level in a template. ie.
^= content_for_draggable "My Title" do
foo
bar
^= end
The content_for_draggable template accepts a block and yields to the inner content and then perhapps wraps that content in a series of divs and javascript to create a draggable block. ie ( and using your imagination )
tdef :content_for_draggable, "title", <<-END
< header stuff with %= title =% >
%= yield =%
</tail stuff>
END
If this is usefull then please give me feedback. I know at the moment that
the regular expressions are not too fault tolerant and you cannot yet escape the control symbols in the template and I am sure there are many other problems.
Cheers
Brad |
|