[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] Template.rb (2003-10-22

Wejn

10/22/2003 5:06:00 PM

Hi,

I'd like to announce first release of "Template.rb" library:
a not-so-simple template language, which is descendant of my
PHP version with the same name.

While being quite stable, it currently lacks any documentation
and website...

I'm releasing it mainly due to the fact that I currently have
no time to create the docs and I think it could be useful to
someone in this list.

The download URL is:

http://www.fi.muni.cz/~xsafran3/Template.rb-20031022-...

To give you very rough understanding how it works (feels),
here's simple example:

===========================================================================
$ cat a.rb
require 'Template'
t = Template.new
t['a'] = {'a' => 'b', 1 => 'x', 's' => Time.now}
t['b'] = []
t['c'] = ['first', 'second', 'third', 'fourth']
t['n'] = 3
t.load('a.tmpl')
puts t.execute


$ cat a.tmpl
<?tpl each a ?>::@k:: -> ::@v::, <?tpl end ?>
<?tpl each b ?>::@k:: -> ::@v::, <?tpl else ?>No data.<?tpl end ?>
<?tpl run ?>Third element is: ::c[2]::,
while fourth is: ::c[n]::.<?tpl end ?>
<?tpl set _x pow n 8 ?>
<?tpl if eq _x 6561 ?>Fine.<?tpl else ?>Error.<?tpl end ?>
Static ::text:: here.


$ ruby a.rb
a -> b, 1 -> x, s -> Wed Oct 22 19:00:28 CEST 2003,
No data.
Third element is: third,
while fourth is: fourth.

Fine.
Static ::text:: here.


===========================================================================

If you have any comments (or you just happen to like it), don't hesitate
to drop me a note :-)

Sincerely,
Michal
--
Wejn <lists+rubytalk(at)box.cz>
(svamberk.net's Linux section, fi.muni.cz student, linuxfan)
>>> Bored? Want hours of entertainment? <<<
>>> Just set the initdefault to 6! <<<