Sha256: 6e8bbd0f44cfe2577ca145d3b9105936389882c481d89dc62051e51d5c97c070
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
require "execjs" require "steering/source" module Steering module Source def self.path @path ||= ENV["HANDLEBARS_SOURCE_PATH"] || bundled_path end def self.path=(path) @contents = @version = @context = nil @path = path end def self.contents @contents ||= File.read(path) end def self.context @context ||= ExecJS.compile(contents) end def self.runtime_path @runtime_path ||= ENV["HANDLEBARS_RUNTIME_PATH"] || bundled_runtime_path end def self.runtime_path=(runtime_path) @runtime = nil @runtime_path = runtime_path end def self.runtime @runtime_contents ||= File.read(runtime_path) end def self.version @version ||= context.eval("Handlebars.VERSION") end end class << self def version Source.version end def compile(template) template = template.read if template.respond_to?(:read) Source.context.call("Handlebars.precompile", template, { :knownHelpers => known_helpers }) end def context_for(template, extra = "") ExecJS.compile("#{Source.runtime}; #{extra}; var template = Handlebars.template(#{compile(template)})") end def known_helpers Source.known_helpers end def render(template, locals = {}) context_for(template).call("template", locals) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
steering-1.0.0 | lib/steering.rb |