class Template
Attributes
template[RW]
Public Class Methods
default(name)
click to toggle source
# File lib/template.rb, line 68 def self::default(name) case name when :fdelim @@fdelim when :placeholders @@placeholders when :def_template @@def_template else @log.error('Do not know ' << name.to_s) @log.error('Aborting. Bye!') end end
new()
click to toggle source
# File lib/template.rb, line 33 def initialize() @log = @@log @log.level = $log_level template_file = $configuration.template @template = nil if template_file msg = File_Checking::file_check(template_file, :file, :readable ) if !msg ftype = File_Checking::file_type(template_file) if ftype && !ftype.empty? && !ftype[0].downcase.match("(html|xml) .*document") msg = template_file.dup << ' does not look like a valid template file for (x)html: ' << ftype.join('; ') end end if(!msg) @template = File.read(template_file) @log.debug('using template ' << template_file) else @log.warn('Cannot use template ' << template_file << ': ' << msg << "\n\tusing default template") end end end
Public Instance Methods
to_s()
click to toggle source
# File lib/template.rb, line 55 def to_s str = nil if @template && @template.respond_to?(:to_str) str = @template else @log.warn('Empty template, using default!') str = @@def_template end str end