Sha256: a2a33d51f40fc47865c3039f2dde83730402e0cdbf143542e271ca9fcccc9282

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

require 'mini_racer'
require 'cmdlet'
require_relative 'handlebarsjs/version'
require_relative 'handlebarsjs/configuration'
require_relative 'handlebarsjs/javascript'
require_relative 'handlebarsjs/handlebars_snapshot'
require_relative 'handlebarsjs/handlebars'
require_relative 'handlebarsjs/base_helper'
require_relative '_'

# Handlebarsjs is a Ruby wrapper for the Handlebars.js templating engine.
module Handlebarsjs
  HANDLEBARS_LIBRARY_PATH = 'lib/handlebarsjs/javascript/handlebars-4.7.7.js'
  HANDLEBARS_API_PATH = 'lib/handlebarsjs/javascript/handlebars-api.js'

  # raise Handlebarsjs::Error, 'Sample message'
  Error = Class.new(StandardError)

  class << self
    # Get a singleton instance of the Handlebars engine.
    #
    # The engine is exposed as a singleton and that means that if you
    # alter the configuration after calling Handlebarsjs.engine,
    # you will have old helper state attached to the engine.
    #
    # If you need to update your helper state, then run Handlebarsjs.reset
    # to clear the singleton
    def engine
      @engine ||= Handlebarsjs::Handlebars.new
    end

    def reset
      @engine = nil
    end

    def render(template, options = {})
      @engine.process_template(template, options)
    end
  end
end

if ENV.fetch('KLUE_DEBUG', 'false').downcase == 'true'
  namespace = 'Handlebarsjs::Version'
  file_path = $LOADED_FEATURES.find { |f| f.include?('handlebarsjs/version') }
  version   = Handlebarsjs::VERSION.ljust(9)
  puts "#{namespace.ljust(35)} : #{version.ljust(9)} : #{file_path}"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
handlebarsjs-0.6.0 lib/handlebarsjs.rb