Class: Tilt::ERBTemplate

Inherits:
Template show all
Defined in:
lib/frank/tilt.rb

Overview

Direct Known Subclasses

ErubisTemplate

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Instance Method Summary collapse

Methods inherited from Template

#basename, #eval_file, #initialize, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Instance Method Details

#initialize_engineObject



358
359
360
361
# File 'lib/frank/tilt.rb', line 358

def initialize_engine
  return if defined? ::ERB
  require_template_library 'erb'
end

#precompiled(locals) ⇒ Object



392
393
394
395
# File 'lib/frank/tilt.rb', line 392

def precompiled(locals)
  source, offset = super
  [source, offset + 1]
end

#precompiled_postamble(locals) ⇒ Object



380
381
382
383
384
385
386
387
# File 'lib/frank/tilt.rb', line 380

def precompiled_postamble(locals)
  "      \#{super}\n    ensure\n      \#{@outvar} = __original_outvar\n    end\n  RUBY\nend\n"

#precompiled_preamble(locals) ⇒ Object



372
373
374
375
376
377
378
# File 'lib/frank/tilt.rb', line 372

def precompiled_preamble(locals)
  "    begin\n      __original_outvar = \#{@outvar} if defined?(\#{@outvar})\n      \#{super}\n  RUBY\nend\n"

#precompiled_template(locals) ⇒ Object



368
369
370
# File 'lib/frank/tilt.rb', line 368

def precompiled_template(locals)
  @engine.src
end

#prepareObject



363
364
365
366
# File 'lib/frank/tilt.rb', line 363

def prepare
  @outvar = (options[:outvar] || '_erbout').to_s
  @engine = ::ERB.new(data, options[:safe], options[:trim], @outvar)
end