Class: Handlebarer::Template

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/handlebarer/template.rb

Overview

Handlebarer Tilt template for use with JST

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.engine_initialized?Boolean

Ensure V8 is available when engine is initialized

Returns:

  • (Boolean)


10
11
12
# File 'lib/handlebarer/template.rb', line 10

def self.engine_initialized?
  defined? ::V8
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ String

Evaluate the template. Compiles the template for JST

Returns:

  • (String)

    JST-compliant compiled version of the Handlebars template being rendered



24
25
26
27
# File 'lib/handlebarer/template.rb', line 24

def evaluate(scope, locals, &block)
  c = Handlebarer::Compiler.new
  c.compile(data)
end

#initialize_engineObject

Require ‘execjs’ when initializing engine



15
16
17
# File 'lib/handlebarer/template.rb', line 15

def initialize_engine
  require_template_library 'v8'
end

#prepareObject



19
20
# File 'lib/handlebarer/template.rb', line 19

def prepare
end