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

Latest News
icalendar 1.4.0 Released
    Ryan Ahearn - 2013-05-21 23:17
BinData 1.5.0 - source moved to github
    Dion Mendel - 2013-05-21 11:10
v13.5.0 Released !!
    id 774 - 2013-05-18 12:28
Runt v0.9.0 Released
    Matthew Lipper - 2013-05-17 00:11
kramdown 1.0.2 released
    Thomas Leitner - 2013-05-09 06:58

 

Forums | Admin

Discussion Forums: galena-goes-alpha-

Start New Thread Start New Thread

 

Topic Topic Starter Replies Last Post