Sha256: 4183c320d8d477896eb1aa1e81d9adab4ff6502754707d2243da2ae01a235e35

Contents?: true

Size: 715 Bytes

Versions: 3

Compression:

Stored size: 715 Bytes

Contents

require 'tilt/template'

module Handlebarer

  # Handlebarer Tilt template for use with JST
  class Template < Tilt::Template
    self.default_mime_type = 'application/javascript'

    # Ensure V8 is available when engine is initialized
    def self.engine_initialized?
      defined? ::V8
    end

    # Require 'execjs' when initializing engine
    def initialize_engine
      require_template_library 'v8'
    end

    def prepare
    end

    # Evaluate the template. Compiles the template for JST
    # @return [String] JST-compliant compiled version of the Handlebars template being rendered
    def evaluate(scope, locals, &block)
      c = Handlebarer::Compiler.new
      c.compile(data)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
handlebarer-0.0.3 lib/handlebarer/template.rb
handlebarer-0.0.2 lib/handlebarer/template.rb
handlebarer-0.0.1 lib/handlebarer/template.rb