handlebarsjs 0.5.3 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09543cdd93c4a2e1b3e5fd6133bebecdbfb4613cf7a9f7690b9d00f47065f6a5'
4
- data.tar.gz: 90cf3559a41f21fc2cee943e8de76846fe13044a9bcca9917cbf5286db1a53ee
3
+ metadata.gz: 6064a3ae1b125ad1e3e15b35845d7ad996d6b1742e0aacf4bcee1a8d828a2572
4
+ data.tar.gz: 926bd6bb058fc865acd74b2af72678858247b494190c6a3cb6bf2b9a66465084
5
5
  SHA512:
6
- metadata.gz: 9c1ffbb3d4651661bed9271df5cdb879848e1569ab974086ccf802a7b81743128570b976b235d6c597e8b343dfa748e6c22abfcfc54caf87cbd9cf1ca5f3c574
7
- data.tar.gz: 41199fb8108776482009c948b9be8dcb834df02affa351cf338b936f9c59b99545c8b326fd87edacc4bc7effa7255eeb42831b258f2c66ab0c81f769f9cfd977
6
+ metadata.gz: 80dfd3854cdf31fb1a068a3c8713dacc85791e7280b7160f30a8a245ed070487a397e838373b356db791b79a64aa6c07b27e091c1061b51cc1dc358c6305bf45
7
+ data.tar.gz: c29fb792acbe8649679d26879670a9e3742330715146968e001a66814ee3b730e33757b16751b47ca0a1a094b2525a1bdd3f193c17f22e544bf69741abcce432
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [0.5.5](https://github.com/klueless-io/handlebarsjs/compare/v0.5.4...v0.5.5) (2022-07-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add configuration ([ab16612](https://github.com/klueless-io/handlebarsjs/commit/ab16612500b1cf61094b128e14fcecbe1aacde5b))
7
+
8
+ ## [0.5.4](https://github.com/klueless-io/handlebarsjs/compare/v0.5.3...v0.5.4) (2022-07-12)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add inflection: pluralize_number and pluralize_number_word ([33ba59a](https://github.com/klueless-io/handlebarsjs/commit/33ba59a7b0ec86e29ed8ddd5bfd3bb5e91d18123))
14
+
15
+ ## [0.5.3](https://github.com/klueless-io/handlebarsjs/compare/v0.5.2...v0.5.3) (2022-07-12)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * add inflection: pluralize_number and pluralize_number_word ([2f5d6e1](https://github.com/klueless-io/handlebarsjs/commit/2f5d6e11b8cc6cd052496ec3f648423fbacececf))
21
+ * add inflection: pluralize_number and pluralize_number_word ([6590859](https://github.com/klueless-io/handlebarsjs/commit/6590859ddfb3d3402677939d887e70e611d18a97))
22
+
1
23
  ## [0.5.2](https://github.com/klueless-io/handlebarsjs/compare/v0.5.1...v0.5.2) (2022-07-12)
2
24
 
3
25
 
data/lib/_.rb CHANGED
@@ -28,7 +28,6 @@ require_relative 'handlebarsjs/helpers/comparison/or'
28
28
  require_relative 'handlebarsjs/helpers/inflection/ordinal'
29
29
  require_relative 'handlebarsjs/helpers/inflection/ordinalize'
30
30
  require_relative 'handlebarsjs/helpers/inflection/pluralize'
31
- require_relative 'handlebarsjs/helpers/inflection/pluralize_by_number'
32
31
  require_relative 'handlebarsjs/helpers/inflection/pluralize_number'
33
32
  require_relative 'handlebarsjs/helpers/inflection/pluralize_number_word'
34
33
  require_relative 'handlebarsjs/helpers/inflection/singularize'
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Handlebarsjs
4
+ # Register this configuration access extension for Handlebars configuration
5
+ module HandlebarsConfigurationExtension
6
+ def handlebars
7
+ return @handlebars if defined? @handlebars
8
+
9
+ @handlebars = HandlebarsConfiguration.new
10
+ end
11
+ end
12
+
13
+ # handlebars.handlebars_snapshot.add_helper(helper_name, helper)
14
+ # Structure for storing Cmdlet configuration
15
+ class HandlebarsConfiguration
16
+ include KLog::Logging
17
+
18
+ attr_accessor :helpers
19
+
20
+ def initialize
21
+ @helpers = []
22
+ end
23
+
24
+ HelperConfig = Struct.new(:name, :helper)
25
+
26
+ def helper(name, helper)
27
+ @helpers << HelperConfig.new(name, helper)
28
+ end
29
+ end
30
+ end
31
+
32
+ KConfig::Configuration.register(:handlebars, Handlebarsjs::HandlebarsConfigurationExtension)
@@ -5,16 +5,35 @@ module Handlebarsjs
5
5
  class Handlebars < Handlebarsjs::Javascript
6
6
  def initialize
7
7
  super
8
- # Handlebars 4.7.7
9
- handlebars_snapshot.add_library('handlebars', path: Handlebarsjs::HANDLEBARS_LIBRARY_PATH)
10
8
 
11
- # Support functions for working with
12
- handlebars_snapshot.add_library('handlebars-api', path: Handlebarsjs::HANDLEBARS_API_PATH)
9
+ add_libraries
10
+ add_configured_helpers
13
11
  end
14
12
 
15
13
  def process_template(template, options = {})
16
14
  # TODO: process template function may be improved with some type of caching
17
15
  context.call('process_template', template, options)
18
16
  end
17
+
18
+ private
19
+
20
+ def add_libraries
21
+ # Handlebars 4.7.7
22
+ gem_path = Gem.loaded_specs['handlebarsjs'].full_gem_path
23
+
24
+ handlebars_lib_path = File.join(gem_path, Handlebarsjs::HANDLEBARS_LIBRARY_PATH)
25
+ handlebars_api_path = File.join(gem_path, Handlebarsjs::HANDLEBARS_API_PATH)
26
+
27
+ handlebars_snapshot.add_library('handlebars', path: handlebars_lib_path)
28
+
29
+ # Support functions for working with
30
+ handlebars_snapshot.add_library('handlebars-api', path: handlebars_api_path)
31
+ end
32
+
33
+ def add_configured_helpers
34
+ KConfig.configuration.handlebars.helpers.each do |helper_config|
35
+ handlebars_snapshot.add_helper(helper_config.name, helper_config.helper)
36
+ end
37
+ end
19
38
  end
20
39
  end
@@ -6,6 +6,8 @@ module Handlebarsjs
6
6
  # in the correct order. So that new contexts are preloaded
7
7
  # with the handlebars library and the configured helpers.
8
8
  class HandlebarsSnapshot
9
+ include KLog::Logging
10
+
9
11
  attr_reader :scripts
10
12
  attr_reader :helpers
11
13
 
@@ -60,7 +62,8 @@ module Handlebarsjs
60
62
  end
61
63
 
62
64
  def debug
63
- puts script
65
+ data = { scripts: scripts, helpers: helpers }
66
+ log.structure(data)
64
67
  end
65
68
 
66
69
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Handlebarsjs
4
- VERSION = '0.5.3'
4
+ VERSION = '0.5.6'
5
5
  end
data/lib/handlebarsjs.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'mini_racer'
4
4
  require 'cmdlet'
5
5
  require_relative 'handlebarsjs/version'
6
+ require_relative 'handlebarsjs/configuration'
6
7
  require_relative 'handlebarsjs/javascript'
7
8
  require_relative 'handlebarsjs/handlebars_snapshot'
8
9
  require_relative 'handlebarsjs/handlebars'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "handlebarsjs",
3
- "version": "0.5.3",
3
+ "version": "0.5.6",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "handlebarsjs",
9
- "version": "0.5.3",
9
+ "version": "0.5.6",
10
10
  "devDependencies": {
11
11
  "@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
12
12
  "@semantic-release/changelog": "^6.0.1",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handlebarsjs",
3
- "version": "0.5.3",
3
+ "version": "0.5.6",
4
4
  "description": "handlebarsjs GEM wraps the handlebars.js library and provides ruby/javascript interoperability",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebarsjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-12 00:00:00.000000000 Z
11
+ date: 2022-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdlet
@@ -91,8 +91,8 @@ files:
91
91
  - docs/project-plan/project_in_progress.svg
92
92
  - lib/_.rb
93
93
  - lib/handlebarsjs.rb
94
- - lib/handlebarsjs/api.rb
95
94
  - lib/handlebarsjs/base_helper.rb
95
+ - lib/handlebarsjs/configuration.rb
96
96
  - lib/handlebarsjs/handlebars.rb
97
97
  - lib/handlebarsjs/handlebars_snapshot.rb
98
98
  - lib/handlebarsjs/helpers/array/join.rb
@@ -123,7 +123,6 @@ files:
123
123
  - lib/handlebarsjs/helpers/inflection/ordinal.rb
124
124
  - lib/handlebarsjs/helpers/inflection/ordinalize.rb
125
125
  - lib/handlebarsjs/helpers/inflection/pluralize.rb
126
- - lib/handlebarsjs/helpers/inflection/pluralize_by_number.rb
127
126
  - lib/handlebarsjs/helpers/inflection/pluralize_number.rb
128
127
  - lib/handlebarsjs/helpers/inflection/pluralize_number_word.rb
129
128
  - lib/handlebarsjs/helpers/inflection/singularize.rb
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # module Handlebarsjs
4
- # class Handlebars
5
-
6
- # end
7
- # end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Handlebarsjs
4
- module Helpers
5
- # Inflection handling routines, eg. pluralize, singular, ordinalize
6
- module Inflection
7
- # PluralizeByNumber: Returns the plural form of the word based on a count
8
- class PluralizeByNumber < Handlebarsjs::BaseHelper
9
- register_cmdlet(Cmdlet::Inflection::PluralizeByNumber)
10
-
11
- def to_proc
12
- ->(value, count, format, _opts) { wrapper(cmdlet.call(value, count, format)) }
13
- end
14
- end
15
- end
16
- end
17
- end