handlebarsjs 0.5.6 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6064a3ae1b125ad1e3e15b35845d7ad996d6b1742e0aacf4bcee1a8d828a2572
4
- data.tar.gz: 926bd6bb058fc865acd74b2af72678858247b494190c6a3cb6bf2b9a66465084
3
+ metadata.gz: f97d40c892a6138efa85a40317ce6c4f6f629ce96bd365c0846361c96fad7af5
4
+ data.tar.gz: 0bcca7a51b1aa79a8988a72d68fe0c3384fbc68dde3ac06a8f8b7621b835f2a3
5
5
  SHA512:
6
- metadata.gz: 80dfd3854cdf31fb1a068a3c8713dacc85791e7280b7160f30a8a245ed070487a397e838373b356db791b79a64aa6c07b27e091c1061b51cc1dc358c6305bf45
7
- data.tar.gz: c29fb792acbe8649679d26879670a9e3742330715146968e001a66814ee3b730e33757b16751b47ca0a1a094b2525a1bdd3f193c17f22e544bf69741abcce432
6
+ metadata.gz: dd370606ce72b0c94cfb75a2d0b3342b749f5841517128602db72e8ec2543fda37ab113633deb2ca1fe5b2c4b69bf8915acddf5deb09b48a9aade2f108f69a8c
7
+ data.tar.gz: bdd9b529472893a67d2fa0bc069ff36f7f859367308d8b0cecf1621c07ce5574e01fae72335e5ce239b2a6ae72ef76f867ca0a5ca016d6909c731fe19750e92a
data/.rubocop.yml CHANGED
@@ -87,3 +87,6 @@ Layout/SpaceBeforeComma:
87
87
  Enabled: false
88
88
  # My Preferences - End
89
89
 
90
+ Metrics/AbcSize:
91
+ Exclude:
92
+ - "lib/handlebarsjs/handlebars_configuration_defaults.rb"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # [0.6.0](https://github.com/klueless-io/handlebarsjs/compare/v0.5.7...v0.6.0) (2022-07-13)
2
+
3
+
4
+ ### Features
5
+
6
+ * align cmdlet/helper GEM versions ([396bed1](https://github.com/klueless-io/handlebarsjs/commit/396bed1e44a865cca51bed0ba2190d099f69c8d3))
7
+
8
+ ## [0.5.7](https://github.com/klueless-io/handlebarsjs/compare/v0.5.6...v0.5.7) (2022-07-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add catgegory default configurations ([8046805](https://github.com/klueless-io/handlebarsjs/commit/80468055f94e36ea682dbbfd26e7eb527db9ff82))
14
+
15
+ ## [0.5.6](https://github.com/klueless-io/handlebarsjs/compare/v0.5.5...v0.5.6) (2022-07-13)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * add configuration capability to handlebars_snapshot ([06f7ca6](https://github.com/klueless-io/handlebarsjs/commit/06f7ca628018d4a89c9b068c8cae4565a624a3db))
21
+
1
22
  ## [0.5.5](https://github.com/klueless-io/handlebarsjs/compare/v0.5.4...v0.5.5) (2022-07-12)
2
23
 
3
24
 
@@ -1,24 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
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
4
  # handlebars.handlebars_snapshot.add_helper(helper_name, helper)
14
5
  # Structure for storing Cmdlet configuration
15
6
  class HandlebarsConfiguration
16
7
  include KLog::Logging
17
8
 
18
9
  attr_accessor :helpers
10
+ attr_reader :defaults
19
11
 
20
12
  def initialize
21
13
  @helpers = []
14
+ @defaults = Handlebarsjs::HandlebarsConfigurationDefaults.new
22
15
  end
23
16
 
24
17
  HelperConfig = Struct.new(:name, :helper)
@@ -28,5 +21,3 @@ module Handlebarsjs
28
21
  end
29
22
  end
30
23
  end
31
-
32
- KConfig::Configuration.register(:handlebars, Handlebarsjs::HandlebarsConfigurationExtension)
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Handlebarsjs
4
+ # Pre-configure default helpers for each category
5
+ class HandlebarsConfigurationDefaults
6
+ def add_array_defaults
7
+ KConfig.configure do |config|
8
+ config.handlebars.helper(:join, Handlebarsjs::Helpers::Array::Join.new)
9
+ config.handlebars.helper(:join_pre, Handlebarsjs::Helpers::Array::JoinPre.new)
10
+ config.handlebars.helper(:join_post, Handlebarsjs::Helpers::Array::JoinPost.new)
11
+ end
12
+ end
13
+
14
+ def add_case_defaults
15
+ KConfig.configure do |config|
16
+ config.handlebars.helper(:back_slash, Handlebarsjs::Helpers::Case::BackSlash.new)
17
+ config.handlebars.helper(:camel, Handlebarsjs::Helpers::Case::Camel.new)
18
+ config.handlebars.helper(:constant, Handlebarsjs::Helpers::Case::Constant.new)
19
+ config.handlebars.helper(:dash, Handlebarsjs::Helpers::Case::Dash.new)
20
+ config.handlebars.helper(:dot, Handlebarsjs::Helpers::Case::Dot.new)
21
+ config.handlebars.helper(:double_colon, Handlebarsjs::Helpers::Case::DoubleColon.new)
22
+ config.handlebars.helper(:human, Handlebarsjs::Helpers::Case::Human.new)
23
+ config.handlebars.helper(:lamel, Handlebarsjs::Helpers::Case::Lamel.new)
24
+ config.handlebars.helper(:lower, Handlebarsjs::Helpers::Case::Lower.new)
25
+ config.handlebars.helper(:slash, Handlebarsjs::Helpers::Case::Slash.new)
26
+ config.handlebars.helper(:snake, Handlebarsjs::Helpers::Case::Snake.new)
27
+ config.handlebars.helper(:title, Handlebarsjs::Helpers::Case::Title.new)
28
+ config.handlebars.helper(:upper, Handlebarsjs::Helpers::Case::Upper.new)
29
+ end
30
+ end
31
+
32
+ def add_comparison_defaults
33
+ KConfig.configure do |config|
34
+ config.handlebars.helper(:and, Handlebarsjs::Helpers::Comparison::And.new)
35
+ config.handlebars.helper(:default, Handlebarsjs::Helpers::Comparison::Default.new)
36
+ config.handlebars.helper(:eq, Handlebarsjs::Helpers::Comparison::Eq.new)
37
+ config.handlebars.helper(:gt, Handlebarsjs::Helpers::Comparison::Gt.new)
38
+ config.handlebars.helper(:gte, Handlebarsjs::Helpers::Comparison::Gte.new)
39
+ config.handlebars.helper(:lt, Handlebarsjs::Helpers::Comparison::Lt.new)
40
+ config.handlebars.helper(:lte, Handlebarsjs::Helpers::Comparison::Lte.new)
41
+ config.handlebars.helper(:ne, Handlebarsjs::Helpers::Comparison::Ne.new)
42
+ config.handlebars.helper(:or, Handlebarsjs::Helpers::Comparison::Or.new)
43
+ end
44
+ end
45
+
46
+ def add_inflection_defaults
47
+ KConfig.configure do |config|
48
+ config.handlebars.helper(:ordinal, Handlebarsjs::Helpers::Inflection::Ordinal.new)
49
+ config.handlebars.helper(:ordinalize, Handlebarsjs::Helpers::Inflection::Ordinalize.new)
50
+ config.handlebars.helper(:pluralize, Handlebarsjs::Helpers::Inflection::Pluralize.new)
51
+ config.handlebars.helper(:pluralize_number, Handlebarsjs::Helpers::Inflection::PluralizeNumber.new)
52
+ config.handlebars.helper(:pluralize_number_word, Handlebarsjs::Helpers::Inflection::PluralizeNumberWord.new)
53
+ config.handlebars.helper(:singularize, Handlebarsjs::Helpers::Inflection::Singularize.new)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,14 @@
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
+ end
13
+
14
+ KConfig::Configuration.register(:handlebars, Handlebarsjs::HandlebarsConfigurationExtension)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ KConfig.configure do |config|
4
+ config.handlebars.helper(:join, Handlebarsjs::Helpers::Array::Join.new)
5
+ config.handlebars.helper(:join_pre, Handlebarsjs::Helpers::Array::JoinPre.new)
6
+ config.handlebars.helper(:join_post, Handlebarsjs::Helpers::Array::JoinPost.new)
7
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ KConfig.configure do |config|
4
+ config.handlebars.helper(:back_slash, Handlebarsjs::Helpers::Case::BackSlash.new)
5
+ config.handlebars.helper(:camel, Handlebarsjs::Helpers::Case::Camel.new)
6
+ config.handlebars.helper(:constant, Handlebarsjs::Helpers::Case::Constant.new)
7
+ config.handlebars.helper(:dash, Handlebarsjs::Helpers::Case::Dash.new)
8
+ config.handlebars.helper(:dot, Handlebarsjs::Helpers::Case::Dot.new)
9
+ config.handlebars.helper(:double_colon, Handlebarsjs::Helpers::Case::DoubleColon.new)
10
+ config.handlebars.helper(:human, Handlebarsjs::Helpers::Case::Human.new)
11
+ config.handlebars.helper(:lamel, Handlebarsjs::Helpers::Case::Lamel.new)
12
+ config.handlebars.helper(:lower, Handlebarsjs::Helpers::Case::Lower.new)
13
+ config.handlebars.helper(:slash, Handlebarsjs::Helpers::Case::Slash.new)
14
+ config.handlebars.helper(:snake, Handlebarsjs::Helpers::Case::Snake.new)
15
+ config.handlebars.helper(:title, Handlebarsjs::Helpers::Case::Title.new)
16
+ config.handlebars.helper(:upper, Handlebarsjs::Helpers::Case::Upper.new)
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ KConfig.configure do |config|
4
+ config.handlebars.helper(:and, Handlebarsjs::Helpers::Comparison::And.new)
5
+ config.handlebars.helper(:default, Handlebarsjs::Helpers::Comparison::Default.new)
6
+ config.handlebars.helper(:eq, Handlebarsjs::Helpers::Comparison::Eq.new)
7
+ config.handlebars.helper(:gt, Handlebarsjs::Helpers::Comparison::Gt.new)
8
+ config.handlebars.helper(:gte, Handlebarsjs::Helpers::Comparison::Gte.new)
9
+ config.handlebars.helper(:lt, Handlebarsjs::Helpers::Comparison::Lt.new)
10
+ config.handlebars.helper(:lte, Handlebarsjs::Helpers::Comparison::Lte.new)
11
+ config.handlebars.helper(:ne, Handlebarsjs::Helpers::Comparison::Ne.new)
12
+ config.handlebars.helper(:or, Handlebarsjs::Helpers::Comparison::Or.new)
13
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ KConfig.configure do |config|
4
+ config.handlebars.helper(:ordinal, Handlebarsjs::Helpers::Inflection::Ordinal.new)
5
+ config.handlebars.helper(:ordinalize, Handlebarsjs::Helpers::Inflection::Ordinalize.new)
6
+ config.handlebars.helper(:pluralize, Handlebarsjs::Helpers::Inflection::Pluralize.new)
7
+ config.handlebars.helper(:pluralize_number, Handlebarsjs::Helpers::Inflection::PluralizeNumber.new)
8
+ config.handlebars.helper(:pluralize_number_word, Handlebarsjs::Helpers::Inflection::PluralizeNumberWord.new)
9
+ config.handlebars.helper(:singularize, Handlebarsjs::Helpers::Inflection::Singularize.new)
10
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Handlebarsjs
4
- VERSION = '0.5.6'
4
+ VERSION = '0.6.1'
5
5
  end
data/lib/handlebarsjs.rb CHANGED
@@ -3,13 +3,16 @@
3
3
  require 'mini_racer'
4
4
  require 'cmdlet'
5
5
  require_relative 'handlebarsjs/version'
6
- require_relative 'handlebarsjs/configuration'
7
6
  require_relative 'handlebarsjs/javascript'
8
7
  require_relative 'handlebarsjs/handlebars_snapshot'
9
8
  require_relative 'handlebarsjs/handlebars'
10
9
  require_relative 'handlebarsjs/base_helper'
10
+ require_relative 'handlebarsjs/handlebars_configuration_defaults'
11
+ require_relative 'handlebarsjs/handlebars_configuration'
12
+ require_relative 'handlebarsjs/handlebars_configuration_extension'
11
13
  require_relative '_'
12
14
 
15
+ # Handlebarsjs is a Ruby wrapper for the Handlebars.js templating engine.
13
16
  module Handlebarsjs
14
17
  HANDLEBARS_LIBRARY_PATH = 'lib/handlebarsjs/javascript/handlebars-4.7.7.js'
15
18
  HANDLEBARS_API_PATH = 'lib/handlebarsjs/javascript/handlebars-api.js'
@@ -17,7 +20,27 @@ module Handlebarsjs
17
20
  # raise Handlebarsjs::Error, 'Sample message'
18
21
  Error = Class.new(StandardError)
19
22
 
20
- # Your code goes here...
23
+ class << self
24
+ # Get a singleton instance of the Handlebars engine.
25
+ #
26
+ # The engine is exposed as a singleton and that means that if you
27
+ # alter the configuration after calling Handlebarsjs.engine,
28
+ # you will have old helper state attached to the engine.
29
+ #
30
+ # If you need to update your helper state, then run Handlebarsjs.reset
31
+ # to clear the singleton
32
+ def engine
33
+ @engine ||= Handlebarsjs::Handlebars.new
34
+ end
35
+
36
+ def reset
37
+ @engine = nil
38
+ end
39
+
40
+ def render(template, options = {})
41
+ engine.process_template(template, options)
42
+ end
43
+ end
21
44
  end
22
45
 
23
46
  if ENV.fetch('KLUE_DEBUG', 'false').downcase == 'true'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "handlebarsjs",
3
- "version": "0.5.6",
3
+ "version": "0.6.1",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "handlebarsjs",
9
- "version": "0.5.6",
9
+ "version": "0.6.1",
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.6",
3
+ "version": "0.6.1",
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebarsjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.0
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.0
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mini_racer
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '0.6'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '0.6'
55
55
  description: " handlebarsjs GEM wraps the handlebars.js library and provides ruby/javascript
56
56
  interoperability\n"
57
57
  email:
@@ -92,9 +92,12 @@ files:
92
92
  - lib/_.rb
93
93
  - lib/handlebarsjs.rb
94
94
  - lib/handlebarsjs/base_helper.rb
95
- - lib/handlebarsjs/configuration.rb
96
95
  - lib/handlebarsjs/handlebars.rb
96
+ - lib/handlebarsjs/handlebars_configuration.rb
97
+ - lib/handlebarsjs/handlebars_configuration_defaults.rb
98
+ - lib/handlebarsjs/handlebars_configuration_extension.rb
97
99
  - lib/handlebarsjs/handlebars_snapshot.rb
100
+ - lib/handlebarsjs/helpers/array/default_configuration.rb
98
101
  - lib/handlebarsjs/helpers/array/join.rb
99
102
  - lib/handlebarsjs/helpers/array/join_post.rb
100
103
  - lib/handlebarsjs/helpers/array/join_pre.rb
@@ -102,6 +105,7 @@ files:
102
105
  - lib/handlebarsjs/helpers/case/camel.rb
103
106
  - lib/handlebarsjs/helpers/case/constant.rb
104
107
  - lib/handlebarsjs/helpers/case/dash.rb
108
+ - lib/handlebarsjs/helpers/case/default_configuration.rb
105
109
  - lib/handlebarsjs/helpers/case/dot.rb
106
110
  - lib/handlebarsjs/helpers/case/double_colon.rb
107
111
  - lib/handlebarsjs/helpers/case/human.rb
@@ -113,6 +117,7 @@ files:
113
117
  - lib/handlebarsjs/helpers/case/upper.rb
114
118
  - lib/handlebarsjs/helpers/comparison/and.rb
115
119
  - lib/handlebarsjs/helpers/comparison/default.rb
120
+ - lib/handlebarsjs/helpers/comparison/default_configuration.rb
116
121
  - lib/handlebarsjs/helpers/comparison/eq.rb
117
122
  - lib/handlebarsjs/helpers/comparison/gt.rb
118
123
  - lib/handlebarsjs/helpers/comparison/gte.rb
@@ -120,6 +125,7 @@ files:
120
125
  - lib/handlebarsjs/helpers/comparison/lte.rb
121
126
  - lib/handlebarsjs/helpers/comparison/ne.rb
122
127
  - lib/handlebarsjs/helpers/comparison/or.rb
128
+ - lib/handlebarsjs/helpers/inflection/default_configuration.rb
123
129
  - lib/handlebarsjs/helpers/inflection/ordinal.rb
124
130
  - lib/handlebarsjs/helpers/inflection/ordinalize.rb
125
131
  - lib/handlebarsjs/helpers/inflection/pluralize.rb