Method: Tenjin::Template#initialize
- Defined in:
- lib/tenjin.rb
#initialize(filename = nil, options = {}) ⇒ Template
initializer of Template class.
options:
- :escapefunc
-
function name to escape value (default ‘escape’)
- :preamble
-
preamble such as “_buf = ”” (default nil)
- :postamble
-
postamble such as “_buf.to_s” (default nil)
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/tenjin.rb', line 509 def initialize(filename=nil, ={}) if filename.is_a?(Hash) = filename filename = nil end @filename = filename @escapefunc = [:escapefunc] || ESCAPE_FUNCTION @preamble = [:preamble] == true ? "_buf = #{init_buf_expr()}; " : [:preamble] @postamble = [:postamble] == true ? finish_buf_expr() : [:postamble] @input = [:input] @trace = [:trace] || TRACE @args = nil # or array of argument names if @input convert(@input, filename) elsif filename convert_file(filename) end end |