handlebarsjs 0.5.3 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/lib/_.rb +0 -1
- data/lib/handlebarsjs/configuration.rb +32 -0
- data/lib/handlebarsjs/handlebars.rb +23 -4
- data/lib/handlebarsjs/handlebars_snapshot.rb +4 -1
- data/lib/handlebarsjs/version.rb +1 -1
- data/lib/handlebarsjs.rb +1 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +3 -4
- data/lib/handlebarsjs/api.rb +0 -7
- data/lib/handlebarsjs/helpers/inflection/pluralize_by_number.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6064a3ae1b125ad1e3e15b35845d7ad996d6b1742e0aacf4bcee1a8d828a2572
|
4
|
+
data.tar.gz: 926bd6bb058fc865acd74b2af72678858247b494190c6a3cb6bf2b9a66465084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
12
|
-
|
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
|
-
|
65
|
+
data = { scripts: scripts, helpers: helpers }
|
66
|
+
log.structure(data)
|
64
67
|
end
|
65
68
|
|
66
69
|
private
|
data/lib/handlebarsjs/version.rb
CHANGED
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
|
+
"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.
|
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
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.
|
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-
|
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
|
data/lib/handlebarsjs/api.rb
DELETED
@@ -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
|