handlebars-helpers 0.0.5 → 0.0.73
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 +4 -4
- data/.github/workflows/ruby.yml +2 -3
- data/.gitignore +1 -0
- data/.handlebars_helpers.json +956 -0
- data/.handlebars_string_formatters.json +137 -0
- data/.rubocop.yml +4 -2
- data/.vscode/settings.json +6 -0
- data/Gemfile +3 -0
- data/README.md +31 -3
- data/Rakefile +1 -0
- data/STORIES.md +55 -7
- data/USAGE.md +1 -1
- data/bin/console +1 -1
- data/handlebars-helpers.gemspec +10 -1
- data/lib/handlebars/helpers.rb +2 -0
- data/lib/handlebars/helpers/base_helper.rb +36 -0
- data/lib/handlebars/helpers/base_safe_string_helper.rb +17 -0
- data/lib/handlebars/helpers/code_ruby/classify.rb +40 -0
- data/lib/handlebars/helpers/code_ruby/deconstantize.rb +48 -0
- data/lib/handlebars/helpers/code_ruby/demodulize.rb +58 -0
- data/lib/handlebars/helpers/code_ruby/foreign_key.rb +49 -0
- data/lib/handlebars/helpers/code_ruby/tableize.rb +35 -0
- data/lib/handlebars/helpers/comparison/and.rb +44 -0
- data/lib/handlebars/helpers/comparison/default.rb +66 -0
- data/lib/handlebars/helpers/comparison/eq.rb +35 -0
- data/lib/handlebars/helpers/comparison/gt.rb +35 -0
- data/lib/handlebars/helpers/comparison/gte.rb +43 -0
- data/lib/handlebars/helpers/comparison/lt.rb +35 -0
- data/lib/handlebars/helpers/comparison/lte.rb +43 -0
- data/lib/handlebars/helpers/comparison/ne.rb +35 -0
- data/lib/handlebars/helpers/comparison/or.rb +56 -0
- data/lib/handlebars/helpers/configuration.rb +72 -0
- data/lib/handlebars/helpers/inflection/ordinal.rb +58 -0
- data/lib/handlebars/helpers/inflection/ordinalize.rb +59 -0
- data/lib/handlebars/helpers/inflection/pluralize.rb +36 -0
- data/lib/handlebars/helpers/inflection/pluralize_by_number.rb +60 -0
- data/lib/handlebars/helpers/inflection/singularize.rb +35 -0
- data/lib/handlebars/helpers/misc/noop.rb +36 -0
- data/lib/handlebars/helpers/misc/safe.rb +37 -0
- data/lib/handlebars/helpers/register_helpers.rb +73 -0
- data/lib/handlebars/helpers/string_formatting/append_if.rb +42 -0
- data/lib/handlebars/helpers/string_formatting/back_slash.rb +33 -0
- data/lib/handlebars/helpers/string_formatting/camel.rb +29 -0
- data/lib/handlebars/helpers/string_formatting/constantize.rb +29 -0
- data/lib/handlebars/helpers/string_formatting/dasherize.rb +33 -0
- data/lib/handlebars/helpers/string_formatting/dotirize.rb +33 -0
- data/lib/handlebars/helpers/string_formatting/double_colon.rb +33 -0
- data/lib/handlebars/helpers/string_formatting/downcase.rb +31 -0
- data/lib/handlebars/helpers/string_formatting/format_as.rb +57 -0
- data/lib/handlebars/helpers/string_formatting/humanize.rb +39 -0
- data/lib/handlebars/helpers/string_formatting/lamel.rb +29 -0
- data/lib/handlebars/helpers/string_formatting/padl.rb +58 -0
- data/lib/handlebars/helpers/string_formatting/padr.rb +59 -0
- data/lib/handlebars/helpers/string_formatting/pluserize.rb +29 -0
- data/lib/handlebars/helpers/string_formatting/prepend_if.rb +42 -0
- data/lib/handlebars/helpers/string_formatting/singularize.rb +35 -0
- data/lib/handlebars/helpers/string_formatting/slash.rb +33 -0
- data/lib/handlebars/helpers/string_formatting/snake.rb +33 -0
- data/lib/handlebars/helpers/string_formatting/string.js +511 -0
- data/lib/handlebars/helpers/string_formatting/surround.rb +49 -0
- data/lib/handlebars/helpers/string_formatting/surround_if.rb +43 -0
- data/lib/handlebars/helpers/string_formatting/titleize.rb +39 -0
- data/lib/handlebars/helpers/string_formatting/upcase.rb +31 -0
- data/lib/handlebars/helpers/string_tokenizer.rb +43 -0
- data/lib/handlebars/helpers/template.rb +68 -0
- data/lib/handlebars/helpers/version.rb +1 -1
- metadata +97 -6
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Ruby code handling routines
|
11
|
+
module CodeRuby
|
12
|
+
# Deconstantize: Removes the rightmost segment from the constant expression in the string.
|
13
|
+
class Deconstantize < Handlebars::Helpers::BaseHelper
|
14
|
+
# Parse will deconstantize, remove the rightmost segment from the constant expression in the string.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# puts Deconstantize.new.parse('Net::HTTP')
|
19
|
+
#
|
20
|
+
# Net
|
21
|
+
#
|
22
|
+
# puts Deconstantize.new.parse('::Net::HTTP')
|
23
|
+
#
|
24
|
+
# ::Net
|
25
|
+
#
|
26
|
+
# puts Deconstantize.new.parse('String')
|
27
|
+
#
|
28
|
+
# ""
|
29
|
+
#
|
30
|
+
# puts Deconstantize.new.parse('::String')
|
31
|
+
#
|
32
|
+
# ""
|
33
|
+
#
|
34
|
+
# @param [String] value - name of the ruby constant expression
|
35
|
+
# @return [String] return constant without rightmost segment
|
36
|
+
def parse(value)
|
37
|
+
return '' if value.nil?
|
38
|
+
|
39
|
+
value.deconstantize
|
40
|
+
end
|
41
|
+
|
42
|
+
def handlebars_helper
|
43
|
+
proc { |_context, value| wrapper(parse(value)) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Ruby code handling routines
|
11
|
+
module CodeRuby
|
12
|
+
# Demodulize: Removes the module part from the expression in the string.
|
13
|
+
class Demodulize < Handlebars::Helpers::BaseHelper
|
14
|
+
# Parse will demodulize, aka remove the module part from the expression in the string.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# puts Demodulize.new.parse('ActiveSupport::Inflector::Inflections')
|
19
|
+
#
|
20
|
+
# Inflections
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# demodulize('ActiveSupport::Inflector::Inflections') # => "Inflections"
|
24
|
+
# demodulize('Inflections') # => "Inflections"
|
25
|
+
# demodulize('::Inflections') # => "Inflections"
|
26
|
+
# demodulize('') # => ""
|
27
|
+
#
|
28
|
+
# puts Demodulize.new.parse('Inflections')
|
29
|
+
#
|
30
|
+
# Inflections
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
#
|
34
|
+
# puts Demodulize.new.parse('::Inflections')
|
35
|
+
#
|
36
|
+
# Inflections
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
#
|
40
|
+
# puts Demodulize.new.parse('')
|
41
|
+
#
|
42
|
+
# ""
|
43
|
+
#
|
44
|
+
# @param [String] value - name of the ruby module and class name separated by ::
|
45
|
+
# @return [String] value demodulize, aka class name without module
|
46
|
+
def parse(value)
|
47
|
+
return '' if value.nil?
|
48
|
+
|
49
|
+
value.demodulize
|
50
|
+
end
|
51
|
+
|
52
|
+
def handlebars_helper
|
53
|
+
proc { |_context, value| wrapper(parse(value)) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Ruby code handling routines
|
11
|
+
module CodeRuby
|
12
|
+
# Foreign Key: Creates a foreign key name from a class name
|
13
|
+
# +separate_class_name_and_id_with_underscore+ sets whether
|
14
|
+
# the method should put '_' between the name and 'id'.
|
15
|
+
class ForeignKey < Handlebars::Helpers::BaseHelper
|
16
|
+
# Parse will Creates a foreign key name from a class name
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
#
|
20
|
+
# puts ForeignKey.new.parse('Message')
|
21
|
+
#
|
22
|
+
# message_id
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# puts ForeignKey.new.parse('Message', class_id_underscored: false)
|
27
|
+
#
|
28
|
+
# messageid
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
#
|
32
|
+
# puts ForeignKey.new.parse('Admin::Post')
|
33
|
+
#
|
34
|
+
# post_id
|
35
|
+
#
|
36
|
+
# @param [String] class_name - name of class
|
37
|
+
# @param [Boolean] class_id_underscored: - optional named value (defaults to true) - is the class and ID to be separated by underscore?
|
38
|
+
# @return [String] value converted to separate_class_name_and_id_with_underscore
|
39
|
+
def parse(class_name, class_id_underscored: true)
|
40
|
+
class_name.foreign_key(class_id_underscored)
|
41
|
+
end
|
42
|
+
|
43
|
+
def handlebars_helper
|
44
|
+
proc { |_context, class_name, class_id_underscored| wrapper(parse(class_name, class_id_underscored: class_id_underscored)) }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Ruby code handling routines
|
11
|
+
module CodeRuby
|
12
|
+
# Tableize: Creates the name of a table like Rails does when converting models to table names
|
13
|
+
class Tableize < Handlebars::Helpers::BaseHelper
|
14
|
+
# Parse will creates the name of a table like Rails does when converting models to table names
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# puts Tableize.new.parse('product category')
|
19
|
+
#
|
20
|
+
# product_categories
|
21
|
+
#
|
22
|
+
# @param [String] value - name of the table
|
23
|
+
# @return [String] value converted to table case with pluralization
|
24
|
+
def parse(value)
|
25
|
+
# tokenizer.parse(value, separator: '_', forced_separator: true).classify
|
26
|
+
tokenizer.parse(value).tableize
|
27
|
+
end
|
28
|
+
|
29
|
+
def handlebars_helper
|
30
|
+
proc { |_context, value| wrapper(parse(value)) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
11
|
+
module Comparison
|
12
|
+
# And: Block helper that renders a block if **all of** the given values are truthy. If an inverse block is specified it will be rendered when falsy.
|
13
|
+
class And < Handlebars::Helpers::BaseHelper
|
14
|
+
# Parse will And: Block helper that renders a block if **all of** the given values are truthy. If an inverse block is specified it will be rendered when falsy.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# {{#if (and p1 p2 p3 p4 p5)}}
|
19
|
+
# found
|
20
|
+
# {{/if}}
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# {{#if (and name age)}}
|
26
|
+
# {{name}}-{{age}}
|
27
|
+
# {{else}}
|
28
|
+
# no name or age
|
29
|
+
# {{/if}}
|
30
|
+
#
|
31
|
+
# @param values list of values (via *splat) to be checked via AND condition
|
32
|
+
# @return [String] return block when every value is truthy
|
33
|
+
def parse(values)
|
34
|
+
values.all? { |value| value }
|
35
|
+
end
|
36
|
+
|
37
|
+
def handlebars_helper
|
38
|
+
# Exclude last paramater which is the context V8::Object
|
39
|
+
proc { |_context, *values| wrapper(parse(values[0..-2])) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_safe_string_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
11
|
+
module Comparison
|
12
|
+
# Default: Returns the first value that is not nil or undefined, otherwise the 'default' value is returned.
|
13
|
+
class Default < Handlebars::Helpers::BaseSafeStringHelper
|
14
|
+
# Parse will Default: Returns the first value that is not nil or undefined, otherwise the 'default' value is returned.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# emotion = nil
|
19
|
+
# puts Default.new.parse(emotion, 'happy')
|
20
|
+
#
|
21
|
+
# happy
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# emotion = 'sad'
|
26
|
+
# puts Default.new.parse(emotion, 'happy')
|
27
|
+
#
|
28
|
+
# sad
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
#
|
32
|
+
# david = nil
|
33
|
+
# lisa = nil
|
34
|
+
# ben = nil
|
35
|
+
# puts Default.new.parse(david, lisa, ben, 'happy')
|
36
|
+
#
|
37
|
+
# happy
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
#
|
41
|
+
# david = nil
|
42
|
+
# lisa = sad
|
43
|
+
# ben = mad
|
44
|
+
# puts Default.new.parse(david, lisa, ben, 'happy')
|
45
|
+
#
|
46
|
+
# sad
|
47
|
+
#
|
48
|
+
# @param [Object] *values - one or more paramaters that may or may not contain nil
|
49
|
+
# @param [String] default_value - the last paramater will be the default value
|
50
|
+
# @return [String] value or default value
|
51
|
+
def parse(values)
|
52
|
+
default_value = values[-1]
|
53
|
+
|
54
|
+
find_value = values[0..-2].find { |value| !value.nil? }
|
55
|
+
|
56
|
+
find_value || default_value
|
57
|
+
end
|
58
|
+
|
59
|
+
def handlebars_helper
|
60
|
+
# Exclude last paramater which is the context V8::Object
|
61
|
+
proc { |_context, *values| wrapper(parse(values[0..-2])) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
11
|
+
module Comparison
|
12
|
+
# Eq: Block helper that renders a block if `a` is **equal to** `b`. If an inverse block is specified it will be rendered when falsy.
|
13
|
+
class Eq < Handlebars::Helpers::BaseHelper
|
14
|
+
# Parse will Eq: Block helper that renders a block if `a` is **equal to** `b`. If an inverse block is specified it will be rendered when falsy.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# puts Eq.new.parse('aaa', 'aaa')
|
19
|
+
#
|
20
|
+
# Truthy
|
21
|
+
#
|
22
|
+
# @param [String] lhs - left hand side value
|
23
|
+
# @param [String] rhs - right hand side value
|
24
|
+
# @return [String] truthy value if left hand side equals right hand side
|
25
|
+
def parse(lhs, rhs)
|
26
|
+
lhs == rhs
|
27
|
+
end
|
28
|
+
|
29
|
+
def handlebars_helper
|
30
|
+
proc { |_context, lhs, rhs| wrapper(parse(lhs, rhs)) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
11
|
+
module Comparison
|
12
|
+
# Gt: (greater than) Block helper that renders a block if `a` is **greater than** `b`. If an inverse block is specified it will be rendered when falsy.
|
13
|
+
class Gt < Handlebars::Helpers::BaseHelper
|
14
|
+
# Parse will Gt: (greater than) Block helper that renders a block if `a` is **greater than** `b`. If an inverse block is specified it will be rendered when falsy.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# puts Gt.new.parse(2, 1)
|
19
|
+
#
|
20
|
+
# Truthy
|
21
|
+
#
|
22
|
+
# @param [String] lhs - left hand side value
|
23
|
+
# @param [String] rhs - right hand side value
|
24
|
+
# @return [String] truthy value if left hand side GREATER THAN right hand side
|
25
|
+
def parse(lhs, rhs)
|
26
|
+
lhs > rhs
|
27
|
+
end
|
28
|
+
|
29
|
+
def handlebars_helper
|
30
|
+
proc { |_context, lhs, rhs| wrapper(parse(lhs, rhs)) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
11
|
+
module Comparison
|
12
|
+
# Gte: (greater than or equal to) Block helper that renders a block if `a` is **greater than** `b`. If an inverse block is specified it will be rendered when falsy.
|
13
|
+
class Gte < Handlebars::Helpers::BaseHelper
|
14
|
+
# Parse will Gte: (greater than or equal to) Block helper that renders a block if `a` is **greater than** `b`. If an inverse block is specified it will be rendered when falsy.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# puts Gte.new.parse(1, 2)
|
19
|
+
#
|
20
|
+
# Falsey
|
21
|
+
#
|
22
|
+
# puts Gte.new.parse(1, 1)
|
23
|
+
#
|
24
|
+
# Truthy
|
25
|
+
#
|
26
|
+
# puts Gte.new.parse(2, 1)
|
27
|
+
#
|
28
|
+
# Truthy
|
29
|
+
#
|
30
|
+
# @param [String] lhs - left hand side value
|
31
|
+
# @param [String] rhs - right hand side value
|
32
|
+
# @return [String] truthy value if left hand side GREATER THAN or EQUAL TO right hand side
|
33
|
+
def parse(lhs, rhs)
|
34
|
+
lhs >= rhs
|
35
|
+
end
|
36
|
+
|
37
|
+
def handlebars_helper
|
38
|
+
proc { |_context, lhs, rhs| wrapper(parse(lhs, rhs)) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
require 'handlebars/helpers/base_helper'
|
7
|
+
|
8
|
+
module Handlebars
|
9
|
+
module Helpers
|
10
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
11
|
+
module Comparison
|
12
|
+
# Lt: (less than) Block helper that renders a block if `a` is **less than** `b`. If an inverse block is specified it will be rendered when falsy.
|
13
|
+
class Lt < Handlebars::Helpers::BaseHelper
|
14
|
+
# Parse will Lt: (less than) Block helper that renders a block if `a` is **less than** `b`. If an inverse block is specified it will be rendered when falsy.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# puts Lt.new.parse(1, 2)
|
19
|
+
#
|
20
|
+
# Truthy
|
21
|
+
#
|
22
|
+
# @param [String] lhs - left hand side value
|
23
|
+
# @param [String] rhs - right hand side value
|
24
|
+
# @return [String] truthy value if left hand side LESS THAN right hand side
|
25
|
+
def parse(lhs, rhs)
|
26
|
+
lhs < rhs
|
27
|
+
end
|
28
|
+
|
29
|
+
def handlebars_helper
|
30
|
+
proc { |_context, lhs, rhs| wrapper(parse(lhs, rhs)) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|