Module: Handlebarsjs

Defined in:
lib/handlebarsjs.rb,
lib/handlebarsjs/version.rb,
lib/handlebarsjs/handlebars.rb,
lib/handlebarsjs/javascript.rb,
lib/handlebarsjs/base_helper.rb,
lib/handlebarsjs/helpers/case/dot.rb,
lib/handlebarsjs/helpers/str/padl.rb,
lib/handlebarsjs/helpers/str/padr.rb,
lib/handlebarsjs/helpers/case/dash.rb,
lib/handlebarsjs/helpers/misc/safe.rb,
lib/handlebarsjs/helpers/array/join.rb,
lib/handlebarsjs/helpers/case/camel.rb,
lib/handlebarsjs/helpers/case/human.rb,
lib/handlebarsjs/helpers/case/lamel.rb,
lib/handlebarsjs/helpers/case/lower.rb,
lib/handlebarsjs/helpers/case/slash.rb,
lib/handlebarsjs/helpers/case/snake.rb,
lib/handlebarsjs/helpers/case/title.rb,
lib/handlebarsjs/helpers/case/upper.rb,
lib/handlebarsjs/handlebars_snapshot.rb,
lib/handlebarsjs/helpers/case/constant.rb,
lib/handlebarsjs/helpers/comparison/eq.rb,
lib/handlebarsjs/helpers/comparison/gt.rb,
lib/handlebarsjs/helpers/comparison/lt.rb,
lib/handlebarsjs/helpers/comparison/ne.rb,
lib/handlebarsjs/helpers/comparison/or.rb,
lib/handlebarsjs/helpers/array/join_pre.rb,
lib/handlebarsjs/helpers/comparison/and.rb,
lib/handlebarsjs/helpers/comparison/gte.rb,
lib/handlebarsjs/helpers/comparison/lte.rb,
lib/handlebarsjs/helpers/array/join_post.rb,
lib/handlebarsjs/helpers/case/back_slash.rb,
lib/handlebarsjs/handlebars_configuration.rb,
lib/handlebarsjs/helpers/misc/format_json.rb,
lib/handlebarsjs/helpers/case/double_colon.rb,
lib/handlebarsjs/helpers/comparison/default.rb,
lib/handlebarsjs/helpers/inflection/ordinal.rb,
lib/handlebarsjs/helpers/inflection/pluralize.rb,
lib/handlebarsjs/helpers/inflection/ordinalize.rb,
lib/handlebarsjs/helpers/inflection/singularize.rb,
lib/handlebarsjs/handlebars_configuration_defaults.rb,
lib/handlebarsjs/handlebars_configuration_extension.rb,
lib/handlebarsjs/helpers/inflection/pluralize_number.rb,
lib/handlebarsjs/helpers/inflection/pluralize_number_word.rb

Overview

Handlebarsjs is a Ruby wrapper for the Handlebars.js templating engine.

Defined Under Namespace

Modules: HandlebarsConfigurationExtension, Helpers Classes: BaseHelper, Handlebars, HandlebarsConfiguration, HandlebarsConfigurationDefaults, HandlebarsSnapshot, Javascript

Constant Summary collapse

HANDLEBARS_LIBRARY_PATH =
'lib/handlebarsjs/javascript/handlebars-4.7.7.js'
HANDLEBARS_API_PATH =
'lib/handlebarsjs/javascript/handlebars-api.js'
HANDLEBARS_HELPERS_PATH =
'lib/handlebarsjs/javascript/handlebars-helpers.js'
Error =

raise Handlebarsjs::Error, ‘Sample message’

Class.new(StandardError)
VERSION =
'0.14.2'

Class Method Summary collapse

Class Method Details

.engineObject

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



33
34
35
# File 'lib/handlebarsjs.rb', line 33

def engine
  @engine ||= Handlebarsjs::Handlebars.new
end

.render(template, options = {}) ⇒ Object



41
42
43
# File 'lib/handlebarsjs.rb', line 41

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

.resetObject



37
38
39
# File 'lib/handlebarsjs.rb', line 37

def reset
  @engine = nil
end