class Tilt::Template
def initialize(file=nil, line=nil, options=nil)
a block is required.
it should read template data and return as a String. When file is nil,
default, template data is read from the file. When a block is given,
Create a new template with the file, line, and options specified. By
def initialize(file=nil, line=nil, options=nil) @file, @line, @options = nil, 1, nil process_arg(options) process_arg(line) process_arg(file) raise ArgumentError, "file or block required" unless @file || block_given? @options ||= {} set_compiled_method_cache # Force the encoding of the input data @default_encoding = @options.delete :default_encoding # Skip encoding detection from magic comments and forcing that encoding # for compiled templates @skip_compiled_encoding_detection = @options.delete :skip_compiled_encoding_detection # load template data and prepare (uses binread to avoid encoding issues) @data = block_given? ? yield(self) : read_template_file if @data.respond_to?(:force_encoding) if default_encoding @data = @data.dup if @data.frozen? @data.force_encoding(default_encoding) end if !@data.valid_encoding? raise Encoding::InvalidByteSequenceError, "#{eval_file} is not valid #{@data.encoding}" end end prepare end