=begin = HTML/Template Ruby extension for HTML/Template == HTML/Template This module deals with HTML template by CGI scripts and use a complete selectivity between design and logic easily. You can deal with a nested block, a loop and a conditional expression. Simpel example, see below. template file test.html
My Path is set to Ruby script require "html/template" tmpl = HTML::Template.new("./test.html") tmpl.param({ 'home' => ENV['HOME'], 'path' => ENV['PATH'] }) print "Content-Type: text/html\n\n" print tmpl.output == INSTALL using install.rb % tar xvzf html-template-x.xx.tar.gz % cd html-template-x.xx % ruby install.rb config % ruby install.rb setup % su # ruby install.rb install == Template File === TAGS You can use original style tag or valid HTML comment style tag. --- --- When you call HTML::Template#param ({PARAMETER_NAME => VAL}), tags will be simply replaced to VAL. --- --- --- --- It allows you to separate a section of text and give it a name It would be able to make them loop or conditional expression. And, it can be nested. --- --- A file specified by FILE_NAME is simply inserted to a template file. The template file will be treated as a merged template. If you pass the path param to HTML::Template.new , include file will be searched under the path. == HTML::Template CLASS === CLASS METHODS --- HTML::Template.new(params = {}) Creates a HTML::Template object. Given a file name to its first argument, use this file as a template. Also you can pass params as Hash. The options are below * filename template filename * path template search path. you can specified as String or Array of String. === METHODS --- HTML::Template#load(file) Load template file. --- HTML::Template#set_html(html) Setting up a string as a template. --- HTML::Template#param(hash = {}) --- HTML::Template#expand(hash = {}) Specifies a string or a loop by Hash for a substitute. When specifying more than a loop simultaneously, value of the hash becomes an array. --- HTML::Template#node(name) --- HTML::Template#loop(name) --- HTML::Template#cond(name) Stands a loop and a conditional expression specified by Retrieves HTML::TemplateNode object. --- HTML::Template#output --- HTML::Template#to_s Returns the final result. == HTML::TemplateNode CLASS This is a class for a loop or a conditional expression. An instance consists of HTML::Template Class and HTML::TemplateNode CLASS. === METHODS --- HTML::TemplateNode#node(name) Stands a loop or a conditional expression specified by Returns HTML::TemplateNode object. Is only used for nested. --- HTML::TemplateNode#param(hash = {}) --- HTML::TemplateNode#expand(hash = {}) --- HTML::TemplateNode#add(hash = {}) Specifies a string or a loop by Hash for a substitute. If you don't call the method, the block won't be displayed. == A LOOP This sample is a displaying list of environment valiables.