From: Makoto Kuwata Date: 2004-03-26T22:28:46+09:00 Subject: Re: [ANN] Kwartz (2004-03-19) released Andreas Schwarz wrote: >module MyTemplate > def MyTemplate::expand(data) > user = data(:user) > list = data(:list) > # any other "global" variables needed by the template > > # ruby code generated by kwartz > end >end > >It's certainly ugly, but I can't think of anything else. Or is there a >way to set variables from the contents of a hash? I created a utility script 'mkmethod'. http://www.kuwata-lab.com/webtech/kwartz/kwartz_2004-03-26_beta.tar.gz Example: ==================== bash$ ./mkmethod -h Usage: mkmethod [-p file] [-l lang] [-M module] [-m method] [-s] file.html Options: -p file : presentation logic file -l lang : ruby / eruby / erb (default 'ruby') -M module : module name (default none) -m method : method name (default 'expand_' + file) -s : sanitizing (equals to '--escape=true') --name=value : options for kwartz bash$ ./mkmethod -p hoge.plogic hoge.html def expand_hoge(_args) user = _args[:user] list = _args[:list] print "Hello " print user print "!\n" for item in list do print "\n" end end bash$ ./mkmethod -p hoge.plogic -M Hoge -l erb hoge.html module Hoge include ERB::Util def self.expand_hoge(_args) user = _args[:user] list = _args[:list] _erbout = ''; _erbout.concat "Hello "; _erbout.concat(( user ).to_s); _erbout.concat "!\n" for item in list do _erbout.concat "\n" end _erbout end end ==================== I hope you'd like it. -- regards, kwa