handlebarsjs 0.13.0 → 0.14.0

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: f82a12060506efbddff4c69305414c8ad24cbecf14a897eae1805b6ae40a7fa5
4
- data.tar.gz: 7d4b3aef04fd506d04fdcee4bcdc3256b6835ac92f856a1e9644ec77ff0cf194
3
+ metadata.gz: a0f26d492757f3c0f1dc7f7740fcd41814108598f544f8dfc61f19a7ed1037f5
4
+ data.tar.gz: dad315a5813be563702486c471d45787754308bd156502dede96db18f9785c79
5
5
  SHA512:
6
- metadata.gz: ed39a269924ab2d1794104373d6dbe38fd6ced1b77a32bf1982f5e7310f7929713b6005d3940ecbf57ea89db54d1709efca994f629ccf4c01f60c7ff6e2c0e36
7
- data.tar.gz: 9c05a160e762f831cd667b8c4ac14e930eed9900507f66429ff25b9b6a71f1193fea05aa49bf43c9d9b8ccf8d3ed93ce97e21d01656b70410a96c3ba8c6652e0
6
+ metadata.gz: 5b59f9ca3cc48cfbbad1bc63c97e9f31ae210aaf8155df382d9ce0957d330a945c0022b739d3112960f597b0f13bbae3ddb45763eeac18c4881d163220e1f62e
7
+ data.tar.gz: a2ecd7df6ee243b9d37cf648c7df7465e6a79c6a7439b2217b8c9de6934d622aa277c850434dd0905df7bec341ed30e3a06f0c3dcb0866a6b492824b34e725a3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [0.13.1](https://github.com/klueless-io/handlebarsjs/compare/v0.13.0...v0.13.1) (2023-10-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update to use cmdlet 13.1 which fixes activesupport issue in 7.1.1 ([c5e438f](https://github.com/klueless-io/handlebarsjs/commit/c5e438f4e2d1727037694cae3f6bc8034bc5d4fe))
7
+
8
+ # [0.13.0](https://github.com/klueless-io/handlebarsjs/compare/v0.12.0...v0.13.0) (2023-07-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * synchronise versions ([95789d5](https://github.com/klueless-io/handlebarsjs/commit/95789d5566d9df9e6e29b42715cf71a9fe4e36b7))
14
+ * synchronise versions ([4cf212b](https://github.com/klueless-io/handlebarsjs/commit/4cf212bb1274bacf61e13a8491c20860e99193ea))
15
+
1
16
  # [0.12.0](https://github.com/klueless-io/handlebarsjs/compare/v0.11.3...v0.12.0) (2023-07-19)
2
17
 
3
18
 
data/Gemfile CHANGED
@@ -14,15 +14,10 @@ group :development, :test do
14
14
  gem 'rubocop'
15
15
  gem 'rubocop-rake', require: false
16
16
  gem 'rubocop-rspec', require: false
17
- end
18
-
19
- group :test do
20
17
  gem 'simplecov', require: false
21
- end
22
18
 
23
- # If local dependency
24
- if ENV['KLUE_LOCAL_GEMS']&.to_s&.downcase == 'true'
25
- group :development, :test do
19
+ # If local dependency
20
+ if ENV['KLUE_LOCAL_GEMS']&.to_s&.downcase == 'true'
26
21
  puts 'Using Local GEMs'
27
22
  gem 'cmdlet' , path: '../cmdlet'
28
23
  end
data/README.md CHANGED
@@ -33,7 +33,7 @@ See [project plan](./docs/project-plan.md)
33
33
 
34
34
  ## Usage
35
35
 
36
- See all [usage examples](./USAGE.md)
36
+ See all [usage examples](./docs/ussage.md)
37
37
 
38
38
 
39
39
 
data/docs/ussage.md ADDED
@@ -0,0 +1,384 @@
1
+ # Handlebars and Ruby Helper Documentation Guide
2
+
3
+ ## Table of Contents
4
+ 1. [Introduction](#introduction)
5
+ 2. [Installation](#installation)
6
+ 3. [Configuration](#configuration)
7
+ 4. [Available Helpers](#available-helpers)
8
+ - [String Helpers](#string-helpers)
9
+ - [Array Helpers](#array-helpers)
10
+ - [Comparison Helpers](#comparison-helpers)
11
+ - [Inflection Helpers](#inflection-helpers)
12
+ - [Case Helpers](#case-helpers)
13
+ - [Miscellaneous Helpers](#miscellaneous-helpers)
14
+ 5. [Advanced Usage](#advanced-usage)
15
+ 6. [Troubleshooting](#troubleshooting)
16
+ 7. [Contributing](#contributing)
17
+
18
+ ## Introduction
19
+ This guide provides an overview of the available helpers that can be used with Handlebars templates in combination with Ruby backends. These helpers simplify common operations like string transformations, array manipulations, and comparison logic to streamline template creation and data formatting.
20
+
21
+ ## Installation
22
+ To use the helpers in your project, add the relevant gem to your `Gemfile` and install it:
23
+
24
+ ```ruby
25
+ # Add this line to your Gemfile
26
+ gem 'handlebarsjs'
27
+
28
+ # Run bundle install to install the gem
29
+ bundle install
30
+ ```
31
+
32
+ ## Configuration
33
+ You can customize the helpers using a configuration block. Below is an example showing how to configure some settings for your helpers in Ruby:
34
+
35
+ ```ruby
36
+ Handlebars.configure do |config|
37
+ config.helper_prefix = 'custom'
38
+ config.auto_escape = true
39
+ # Add other configuration options as needed
40
+ end
41
+ ```
42
+
43
+ To extend the configuration, you can also register the `HandlebarsConfigurationExtension`:
44
+
45
+ ```ruby
46
+ KConfig::Configuration.register(:handlebars, Handlebarsjs::HandlebarsConfigurationExtension)
47
+ ```
48
+
49
+ The `HandlebarsConfigurationDefaults` can be used to preload default helpers for each category:
50
+
51
+ ```ruby
52
+ Handlebarsjs::HandlebarsConfigurationDefaults.new.add_all_defaults
53
+ ```
54
+
55
+ This allows you to pre-configure helpers for arrays, strings, cases, comparisons, and other categories, providing a streamlined setup process for using helpers effectively.
56
+
57
+ ## Available Helpers
58
+
59
+ ### Miscellaneous Helpers
60
+
61
+ #### Safe
62
+ The `safe` helper allows you to output HTML or other special characters without escaping them. This is particularly useful when you want to retain tags or special symbols in your output.
63
+
64
+ Usage:
65
+
66
+ ```handlebars
67
+ {{safe value}}
68
+ ```
69
+
70
+ **Example:**
71
+
72
+ - Input: `<hello name="world" />`
73
+ - Output: `<hello name="world" />`
74
+
75
+ #### FormatJson
76
+ The `format_json` helper is used to format a given value into pretty JSON, which is especially helpful for rendering JSON objects in a human-readable way.
77
+
78
+ Usage:
79
+
80
+ ```handlebars
81
+ {{format_json value}}
82
+ ```
83
+
84
+ **Example:**
85
+
86
+ - Input: `"<hello>World</hello>"`
87
+ - Output: `"&quot;&lt;hello&gt;World&lt;/hello&gt;&quot;"`
88
+
89
+ ### Array Helpers
90
+
91
+ #### JoinPost
92
+ The `join_post` helper joins an array of elements into a single string with a separator, adding the separator at the end of the string.
93
+
94
+ Usage:
95
+
96
+ ```handlebars
97
+ {{join_post values}}
98
+ ```
99
+
100
+ **Example:**
101
+
102
+ - Input: `[1, 2, 3]`
103
+ - Default Separator Output: `1,2,3,`
104
+ - Custom Separator: `{{join_post values "|"}}` results in `1|2|3|`
105
+
106
+ #### Join
107
+ The `join` helper joins an array of elements into a single string with a separator.
108
+
109
+ Usage:
110
+
111
+ ```handlebars
112
+ {{join values}}
113
+ ```
114
+
115
+ **Example:**
116
+
117
+ - Input: `[1, 2, 3]`
118
+ - Default Separator Output: `1,2,3`
119
+ - Custom Separator: `{{join values "|"}}` results in `1|2|3`
120
+
121
+ #### JoinPre
122
+ The `join_pre` helper joins an array of elements into a single string with a separator, adding the separator at the beginning of the string.
123
+
124
+ Usage:
125
+
126
+ ```handlebars
127
+ {{join_pre values}}
128
+ ```
129
+
130
+ **Example:**
131
+
132
+ - Input: `[1, 2, 3]`
133
+ - Default Separator Output: `,1,2,3`
134
+ - Custom Separator: `{{join_pre values "|"}}` results in `|1|2|3`
135
+
136
+ ### Inflection Helpers
137
+
138
+ #### Ordinal
139
+ The `ordinal` helper adds the appropriate suffix to a number to denote its position in an ordered sequence.
140
+
141
+ Usage:
142
+
143
+ ```handlebars
144
+ {{ordinal value}}
145
+ ```
146
+
147
+ **Example:**
148
+
149
+ - Input: `1`
150
+ - Output: `st`
151
+
152
+ - Input: `2`
153
+ - Output: `nd`
154
+
155
+ #### Ordinalize
156
+ The `ordinalize` helper converts a number to its ordinal representation.
157
+
158
+ Usage:
159
+
160
+ ```handlebars
161
+ {{ordinalize value}}
162
+ ```
163
+
164
+ **Example:**
165
+
166
+ - Input: `1`
167
+ - Output: `1st`
168
+
169
+ - Input: `2`
170
+ - Output: `2nd`
171
+
172
+ #### Singularize
173
+ The `singularize` helper converts a word to its singular form.
174
+
175
+ Usage:
176
+
177
+ ```handlebars
178
+ {{singularize value}}
179
+ ```
180
+
181
+ **Example:**
182
+
183
+ - Input: `octopi`
184
+ - Output: `octopus`
185
+
186
+ #### Pluralize
187
+ The `pluralize` helper converts a word to its plural form.
188
+
189
+ Usage:
190
+
191
+ ```handlebars
192
+ {{pluralize value}}
193
+ ```
194
+
195
+ **Example:**
196
+
197
+ - Input: `octopus`
198
+ - Output: `octopi`
199
+
200
+ ### Case Helpers
201
+
202
+ #### Lower
203
+ The `lower` helper converts all characters in a string to lowercase.
204
+
205
+ Usage:
206
+
207
+ ```handlebars
208
+ {{lower value}}
209
+ ```
210
+
211
+ **Example:**
212
+
213
+ - Input: `THE quick BROWN fox`
214
+ - Output: `the quick brown fox`
215
+
216
+ #### Slash
217
+ The `slash` helper converts spaces in a string to forward slashes.
218
+
219
+ Usage:
220
+
221
+ ```handlebars
222
+ {{slash value}}
223
+ ```
224
+
225
+ **Example:**
226
+
227
+ - Input: `the quick brown fox`
228
+ - Output: `the/quick/brown/fox`
229
+
230
+ #### Lamel
231
+ The `lamel` helper converts a string to lower camel case.
232
+
233
+ Usage:
234
+
235
+ ```handlebars
236
+ {{lamel value}}
237
+ ```
238
+
239
+ **Example:**
240
+
241
+ - Input: `the quick brown fox`
242
+ - Output: `theQuickBrownFox`
243
+
244
+ ### Comparison Helpers
245
+
246
+ #### Lte
247
+ The `lte` helper checks if one value is less than or equal to another.
248
+
249
+ Usage:
250
+
251
+ ```handlebars
252
+ {{#if (lte lhs rhs)}} ... {{/if}}
253
+ ```
254
+
255
+ **Example:**
256
+
257
+ - Input: `1 <= 2`
258
+ - Output: `true`
259
+
260
+ #### Eq
261
+ The `eq` helper checks if two values are equal.
262
+
263
+ Usage:
264
+
265
+ ```handlebars
266
+ {{#if (eq lhs rhs)}} ... {{/if}}
267
+ ```
268
+
269
+ **Example:**
270
+
271
+ - Input: `'aaa' == 'aaa'`
272
+ - Output: `true`
273
+
274
+ ### String Helpers
275
+
276
+ #### Padl
277
+ The `padl` helper adds padding to the left side of a string.
278
+
279
+ Usage:
280
+
281
+ ```handlebars
282
+ {{padl value count char}}
283
+ ```
284
+
285
+ **Example:**
286
+
287
+ - Input: `pad-me` with padding count of `10` and character `-`
288
+ - Output: `----pad-me`
289
+
290
+ #### Padr
291
+ The `padr` helper adds padding to the right side of a string.
292
+
293
+ Usage:
294
+
295
+ ```handlebars
296
+ {{padr value count char}}
297
+ ```
298
+
299
+ **Example:**
300
+
301
+ - Input: `pad-me` with padding count of `10` and character `-`
302
+ - Output: `pad-me----`
303
+
304
+ ## Advanced Usage
305
+ For more advanced usage, such as creating custom helpers or extending functionality, you can use the `register_helper` method. Here’s an example to create a custom helper that returns the current date:
306
+
307
+ ```ruby
308
+ handlebars.register_helper(:current_date) do |context|
309
+ Time.now.strftime("%Y-%m-%d")
310
+ end
311
+ ```
312
+
313
+ In Handlebars template:
314
+
315
+ ```handlebars
316
+ <p>Today's Date: {{current_date}}</p>
317
+ ```
318
+
319
+ ## Troubleshooting
320
+ If helpers are not behaving as expected, consider the following tips:
321
+
322
+ - Ensure that all helpers are registered before compiling the template.
323
+ - Verify the input data format matches the expected type for each helper.
324
+ - Check for typos in the helper names used in the templates.
325
+
326
+ ## Contributing
327
+ We welcome contributions to enhance the available helpers and documentation. Feel free to fork the repository and submit pull requests. Make sure to follow our contribution guidelines available in `CONTRIBUTING.md`.
328
+
329
+ For any questions or issues, please create an issue on GitHub.
330
+
331
+ ## File Structure
332
+
333
+ ### lib
334
+
335
+ #### handlebarsjs
336
+
337
+ ##### helpers
338
+
339
+ ###### misc
340
+ - format_json.rb
341
+ - safe.rb
342
+
343
+ ###### array
344
+ - join_pre.rb
345
+ - join.rb
346
+ - join_post.rb
347
+
348
+ ###### inflection
349
+ - singularize.rb
350
+ - pluralize.rb
351
+ - pluralize_number_word.rb
352
+ - ordinal.rb
353
+ - pluralize_number.rb
354
+ - ordinalize.rb
355
+
356
+ ###### case
357
+ - camel.rb
358
+ - title.rb
359
+ - back_slash.rb
360
+ - dot.rb
361
+ - constant.rb
362
+ - lower.rb
363
+ - snake.rb
364
+ - dash.rb
365
+ - human.rb
366
+ - upper.rb
367
+ - lamel.rb
368
+ - slash.rb
369
+ - double_colon.rb
370
+
371
+ ###### comparison
372
+ - and.rb
373
+ - default.rb
374
+ - lt.rb
375
+ - gte.rb
376
+ - eq.rb
377
+ - gt.rb
378
+ - or.rb
379
+ - ne.rb
380
+ - lte.rb
381
+
382
+ ###### str
383
+ - padl.rb
384
+ - padr.rb
@@ -66,7 +66,6 @@ module Handlebarsjs
66
66
  def add_misc_defaults
67
67
  KConfig.configure do |config|
68
68
  config.handlebars.helper(:format_json, Handlebarsjs::Helpers::Misc::FormatJson.new)
69
- config.handlebars.helper(:omit, Handlebarsjs::Helpers::Misc::Omit.new, aliases: %i[ignore comment_out])
70
69
  config.handlebars.helper(:safe, Handlebarsjs::Helpers::Misc::Safe.new)
71
70
  end
72
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Handlebarsjs
4
- VERSION = '0.13.0'
4
+ VERSION = '0.14.0'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "handlebarsjs",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "handlebarsjs",
9
- "version": "0.13.0",
9
+ "version": "0.14.0",
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.13.0",
3
+ "version": "0.14.0",
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.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-19 00:00:00.000000000 Z
11
+ date: 2024-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdlet
@@ -88,6 +88,7 @@ files:
88
88
  - docs/domain_model_custom.drawio
89
89
  - docs/project-plan/project.drawio
90
90
  - docs/project-plan/project_in_progress.svg
91
+ - docs/ussage.md
91
92
  - lib/_.rb
92
93
  - lib/handlebarsjs.rb
93
94
  - lib/handlebarsjs/base_helper.rb