=begin = CHANGES == Release 0.7.1 (2011-11-27) * [bugfix] Tenjin::Template class now considers magic comment in template file. For example:

This template file is treated as utf-8 string

* [bugfix] Add 'FollowSymLinks' option to 'public_html/.htaccess'. That option is necessary to enable mod_rewrite. * [bugfix] Fix 'public_html/hello.rbhtml' to set empty string when request parameter is not set. == Release 0.7.0 (2011-11-24) * [enhance] Support Ruby 1.9. * [enhance] Add 'HtmlHelper#escape_html()' which escapes '\'' into '''. * [change] Change 'HtmlHelper#escape()' to be alias of '#escape_html()', not '#escape_xml()' * [change] '${}' is changed to escape "'" into '''. * [enhance] Fragment cache support ## fragment cache with key ('items/1') and lifetime (60sec) ## use file-base cache store Dir.mkdir('cache.d') unless File.exist?('cache.d') kv_store = Tenjin::FileBaseStore.new('cache.d') Tenjin::Engine.data_cache = kv_store See: http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#fragment-cache * [enhance] (EXPERIMENTAL) Add 'SafeTemplate' and 'SafeEngine' classes which escapes HTML characters automatically. * SafeTemplate and SafeEngine escapes context data except SafeString object. * Using these classes, only '${...}' is available. '#{...}' is inhibited. ## include Tenjin::HtmlHelper include Tenjin::SafeHelper context = { :text1=>"", # will be escaped :text2=>safe_str(""), # not escaped because marked as 'already escaped' } engine = Template::SafeEngine.new() html = engine.render('example.rbhtml', context) ## example.rbhtml: #

text1 = ${@text1}

#

text2 = ${@text2}

## Output: #

text1 = <AAA>

#

text2 =

See: http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#auto-escaping * [enhance] Add new option ':lang' to 'Template.new()' which will be helpful to create M17N page. This feature should be used with preprocessing. ## creates 'example.rbhtml.en.cache' file lang = "en" engine = Tenjin::Engine.new(:preprocess=>true, :lang=>lang) engine.render("example.rbhtml", {}) ## creates 'example.rbhtml.fr.cache' file lang = "fr" engine = Tenjin::Engine.new(:preprocess=>true, :lang=>lang) engine.render("example.rbhtml", {}) See: http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#m17n * [enhance] 'Template' class now supports ':trace' option which prints template filename as HTML comment when importing other template file. ## print '' ## and '' ## when importing other template. engine = Tenjin::Engine.new(:trace=>true) See: http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#trace * [enhance] 'Tenjin::Template' class now accepts ':input' option which represents template file content. input = <Hello ${@name}! END t = Tenjin::Template.new(:input=>input) puts t.render({:name=>"Guest"}) * [enhance] Support logger. require 'logger' Tenjin.logger = Logger.new($stderr) See: http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#logging * [enhance] Add new module 'Tenjin::SafeHelper' which includes 'safe_str()', 'safe_escape()', and 'safe_str?()'. include Tenjin::HtmlHelper include Tenjin::SafeHelper # s = "" puts safe_str?(s) #=> false s = safe_escape(s) # same as SafeString.new(escape(s)) puts safe_str?(s) #=> true puts s #=> <AAA> puts safe_escape(s) #=> <AAA> # s = "" s = safe_str(s) # same as SafeString.new(s) puts safe_str?(s) #=> true puts s #=> puts safe_escape(s) #=> See: http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#auto-escaping * [change] Html tag helpers (such as 'checked()') now returns 'SafeString' object to support both 'Tenjin::Template' and 'Tenjin::SafeTemplate'. * [change] Html tag helpers (such as 'checked()') are moved from 'Tenjin::HtmlHelper' into new module 'Tenjin::HtmlTagHelper'. * [enhance] Add 'new_cycle()' helper which returns values cyclic. ## template class="${cycle}" ## output class="odd" class="even" class="odd" class="even" class="odd" * [enhance] Add new html tag 'js_link()'. js_link('Show', '$().show()') #=> 'Show * [enhance] Add new html tag 'nv()' which generates 'name' and 'value' attributes. nv('gender', 'F') #=> ' name="gender" value="F" nv('gender', 'F', '-') #=> ' name="gender" value="F" id="gender-F" * [enhance] Add 'public_html/rbtenjin.cgi' which is a sample script to use tenjin in CGI script. See: http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#cgi-script * [bugfix] import() now works well with preprocessing enabled. * [change][internal] change test scripts to use 'oktset.rb' instead of test::unit. * [change][internal] add 'FileFinder' class * [change][internal] rewrite 'Engine' class to use 'FileFinder' class * [change][internal] change 'TemplateCache#load()' to make 'timestamp' arg as optional * [change][internal] change a lot of methods of 'Engine' class to be private * [change][internal] rename 'Engine.datastore()' to 'Engine.data_store()' * [change][internal] eliminate timestamp checking of template files * [change][internal] Changed to use File.rename() instead of File.open() + File#flock() when creating template cache file. == Release 0.6.2 (2008-02-24) * Rubinius supported. * Changed to convert texts before expressions into spaces when command-line option '-S' specified. ex. hoge.rbhtml

${item}

ex. result of '-S' ## 0.6.1 $ rbtenjin -S hoge.rbhtml _buf = ''; for item in @list escape((item).to_s); end _buf.to_s ## 0.6.2 $ rbtenjin -S hoge.rbhtml _buf = ''; for item in @list escape((item).to_s); end _buf.to_s == Release 0.6.1 (2007-02-07) === Enhancements * It is able to make any class which includes Tenjin::ContextHelper module as context object class. This is useful if you want to define helper functions as instance method of that class. See section 'Add Your Helper Functions' for details. http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#dev-helpers ex. require 'tenjin' class MyClass include Tenjin::ContextHelper #include Tenjin::HtmlHelper # optional ## define helper functions in current class def link_to(label, url) return "#{escape(label)}" end def render_template(template_name) engine = Tenjin::Engine.new() ## pass self as context object output = engine.render(template_name, self) return output end def main ## set context data as instance variables @label = 'Top' @url = '/' output = render_template('example.rbhtml') print output end end MyClass.new.main() =end