handlebarsjs 0.13.1 → 0.14.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: 7fb064cdd88b0ac385ee41a742f7f7e9d41f4c606fc83ea242aa92d96586382a
4
- data.tar.gz: 9a8746e4dc62d26e166dda98c30123693345c55b27942c252ade1bcb3ee4cfcd
3
+ metadata.gz: 13125c6510ce6aa93cceea51bbc11800d005380782f8ae8e88dfc23af8eedcb3
4
+ data.tar.gz: 22d64cf7ef7a4d64ba4bc0ace93c675b4d354d93d98cdc1556e12da7ed1d63c9
5
5
  SHA512:
6
- metadata.gz: 40c760f07ad899aa8b9b4427b101faf5e97ddfb92daac0fb71d72de5f206f988c7724349db43586fc7157e685ea83d264232ce36218581422065050e6a50f539
7
- data.tar.gz: 9d52c07d1e63307dd33c565bba8f29ce8aadb55954f1a33840cec05967bcf71eb0bb49eca4d17b57953923ee4a9c0692992bc6c4fc25ee6ca6cffec2eb654914
6
+ metadata.gz: 1d7216230be7a97dc78f9eb95cb8d7259750ad715c8b8c0733e7d7406d0b4017c4d850e2a64b08f78056a98c0bad8669af12950ff3fc48ffc2634b098b5da3d7
7
+ data.tar.gz: 2d8a220a507a9e264aa7641fcf15faacaf111428f2f3d3276b9ae17175d8fbf213dd9593f7cbb478dc0e8112578e03be0441e970a0f8f9fcac901549b3c514b4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [0.14.0](https://github.com/klueless-io/handlebarsjs/compare/v0.13.1...v0.14.0) (2024-10-14)
2
+
3
+
4
+ ### Features
5
+
6
+ * update usage documentation ([934f252](https://github.com/klueless-io/handlebarsjs/commit/934f252e8ed3816f2d5d20272d42ea338486fbc1))
7
+
8
+ ## [0.13.1](https://github.com/klueless-io/handlebarsjs/compare/v0.13.0...v0.13.1) (2023-10-17)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update to use cmdlet 13.1 which fixes activesupport issue in 7.1.1 ([c5e438f](https://github.com/klueless-io/handlebarsjs/commit/c5e438f4e2d1727037694cae3f6bc8034bc5d4fe))
14
+
1
15
  # [0.13.0](https://github.com/klueless-io/handlebarsjs/compare/v0.12.0...v0.13.0) (2023-07-19)
2
16
 
3
17
 
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/usage.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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Handlebarsjs
4
- VERSION = '0.13.1'
4
+ VERSION = '0.14.1'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "handlebarsjs",
3
- "version": "0.13.1",
3
+ "version": "0.14.1",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "handlebarsjs",
9
- "version": "0.13.1",
9
+ "version": "0.14.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.13.1",
3
+ "version": "0.14.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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebarsjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.1
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-10-17 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/usage.md
91
92
  - lib/_.rb
92
93
  - lib/handlebarsjs.rb
93
94
  - lib/handlebarsjs/base_helper.rb