handlebars-helpers 0.0.5 → 0.0.65
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 +3 -3
- data/.gitignore +1 -0
- data/.handlebars_helpers.json +901 -0
- data/.handlebars_string_formatters.json +137 -0
- data/.rubocop.yml +4 -2
- data/.vscode/settings.json +6 -0
- data/Gemfile +3 -0
- data/Rakefile +1 -0
- data/STORIES.md +44 -6
- data/handlebars-helpers.gemspec +2 -0
- 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/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 +82 -3
@@ -0,0 +1,137 @@
|
|
1
|
+
{
|
2
|
+
"formatters": [
|
3
|
+
{
|
4
|
+
"name": "ordinalize",
|
5
|
+
"description": "number value turned to 1st, 2nd, 3rd, 4th etc.",
|
6
|
+
"aliases": ["ordinalize"],
|
7
|
+
"class_namespace": "Handlebars::Helpers::Inflection::Ordinalize",
|
8
|
+
"require_path": "handlebars/helpers/inflection/ordinalize"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"name": "ordinal",
|
12
|
+
"description": "ordinal suffix that would be required for a number, eg. st, nd, rd, th",
|
13
|
+
"aliases": ["ordinal"],
|
14
|
+
"class_namespace": "Handlebars::Helpers::Inflection::Ordinal",
|
15
|
+
"require_path": "handlebars/helpers/inflection/ordinal"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"name": "pluralize",
|
19
|
+
"description": "singular value is converted to plural form",
|
20
|
+
"aliases": ["pluralize", "plural"],
|
21
|
+
"class_namespace": "Handlebars::Helpers::Inflection::Pluralize",
|
22
|
+
"require_path": "handlebars/helpers/inflection/pluralize"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"name": "singularize",
|
26
|
+
"description": "plural value is converted to singular from",
|
27
|
+
"aliases": ["singularize", "singular"],
|
28
|
+
"class_namespace": "Handlebars::Helpers::Inflection::Singularize",
|
29
|
+
"require_path": "handlebars/helpers/inflection/singularize"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"name": "tableize",
|
33
|
+
"description": "creates the name of a table like Rails does when converting models to table names",
|
34
|
+
"aliases": ["tableize"],
|
35
|
+
"class_namespace": "Handlebars::Helpers::CodeRuby::Tableize",
|
36
|
+
"require_path": "handlebars/helpers/code_ruby/tableize"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "back_slash",
|
40
|
+
"description": "convert to back slash notation",
|
41
|
+
"aliases": ["back_slash", "backward_slash", "slash_backward"],
|
42
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::BackSlash",
|
43
|
+
"require_path": "handlebars/helpers/string_formatting/back_slash"
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"name": "camel",
|
47
|
+
"description": "convert to camel case with first word uppercase and following words uppercase",
|
48
|
+
"aliases": ["camel", "camel_upper", "camelUpper", "camelU", "pascalcase"],
|
49
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Camel",
|
50
|
+
"require_path": "handlebars/helpers/string_formatting/camel"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"name": "constantize",
|
54
|
+
"description": "convert to constant case",
|
55
|
+
"aliases": ["constantize", "constant"],
|
56
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Constantize",
|
57
|
+
"require_path": "handlebars/helpers/string_formatting/constantize"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"name": "dasherize",
|
61
|
+
"description": "convert to dash notation",
|
62
|
+
"aliases": ["dasherize", "dashify", "dashcase", "hyphenate"],
|
63
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Dasherize",
|
64
|
+
"require_path": "handlebars/helpers/string_formatting/dasherize"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"name": "dotirize",
|
68
|
+
"description": "convert to dash notation",
|
69
|
+
"aliases": ["dotirize", "dotify", "dotcase"],
|
70
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Dotirize",
|
71
|
+
"require_path": "handlebars/helpers/string_formatting/dotirize"
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"name": "double_colon",
|
75
|
+
"description": "double_colon notation, similar to ruby namespace",
|
76
|
+
"aliases": ["double_colon"],
|
77
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::DoubleColon",
|
78
|
+
"require_path": "handlebars/helpers/string_formatting/double_colon"
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"name": "downcase",
|
82
|
+
"description": "convert all characters to lower case",
|
83
|
+
"aliases": ["downcase", "lowercase"],
|
84
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Downcase",
|
85
|
+
"require_path": "handlebars/helpers/string_formatting/downcase"
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"name": "humanize",
|
89
|
+
"description": "convert text to human case, aka capitalize",
|
90
|
+
"aliases": ["humanize", "capitalize"],
|
91
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Humanize",
|
92
|
+
"require_path": "handlebars/helpers/string_formatting/humanize"
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"name": "lamel",
|
96
|
+
"description": "convert to lamel case with first word lowercase and following words uppercase",
|
97
|
+
"aliases": ["lamel", "camel_lower", "camelLower", "camelL"],
|
98
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Lamel",
|
99
|
+
"require_path": "handlebars/helpers/string_formatting/lamel"
|
100
|
+
},
|
101
|
+
{
|
102
|
+
"name": "pluserize",
|
103
|
+
"description": "convert to plus notation",
|
104
|
+
"aliases": ["pluserize", "plusify", "pluscase"],
|
105
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Pluserize",
|
106
|
+
"require_path": "handlebars/helpers/string_formatting/pluserize"
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"name": "slash",
|
110
|
+
"description": "convert to slash notation, aka forward slash",
|
111
|
+
"aliases": ["slash", "forward_slash", "slash_forward"],
|
112
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Slash",
|
113
|
+
"require_path": "handlebars/helpers/string_formatting/slash"
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"name": "snake",
|
117
|
+
"description": "convert to snake notation",
|
118
|
+
"aliases": ["snake"],
|
119
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Snake",
|
120
|
+
"require_path": "handlebars/helpers/string_formatting/snake"
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"name": "titleize",
|
124
|
+
"description": "value converted to titleize case, aka heading case",
|
125
|
+
"aliases": ["titleize", "heading", "capitalize_all"],
|
126
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Titleize",
|
127
|
+
"require_path": "handlebars/helpers/string_formatting/titleize"
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"name": "upcase",
|
131
|
+
"description": "convert all characters to lower case",
|
132
|
+
"aliases": ["upcase", "uppercase"],
|
133
|
+
"class_namespace": "Handlebars::Helpers::StringFormatting::Upcase",
|
134
|
+
"require_path": "handlebars/helpers/string_formatting/upcase"
|
135
|
+
}
|
136
|
+
]
|
137
|
+
}
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require: rubocop-rake
|
1
2
|
inherit_from: .rubocop_todo.yml
|
2
3
|
|
3
4
|
AllCops:
|
@@ -10,9 +11,9 @@ AllCops:
|
|
10
11
|
|
11
12
|
Metrics/BlockLength:
|
12
13
|
Exclude:
|
13
|
-
- "**/spec
|
14
|
+
- "**/spec/**/*"
|
14
15
|
- "*.gemspec"
|
15
|
-
|
16
|
+
IgnoredMethods:
|
16
17
|
- configure
|
17
18
|
- context
|
18
19
|
- define
|
@@ -77,3 +78,4 @@ Style/AccessorGrouping:
|
|
77
78
|
Layout/SpaceBeforeComma:
|
78
79
|
Enabled: false
|
79
80
|
# My Preferences - End
|
81
|
+
|
data/Gemfile
CHANGED
@@ -17,8 +17,11 @@ group :development, :test do
|
|
17
17
|
gem 'guard-rspec'
|
18
18
|
gem 'guard-rubocop'
|
19
19
|
gem 'rake', '~> 12.0'
|
20
|
+
gem 'rake-compiler', require: false
|
20
21
|
gem 'rspec', '~> 3.0'
|
21
22
|
gem 'rubocop'
|
23
|
+
gem 'rubocop-rake', require: false
|
24
|
+
gem 'rubocop-rspec', require: false
|
22
25
|
end
|
23
26
|
|
24
27
|
# # Temporary path:
|
data/Rakefile
CHANGED
data/STORIES.md
CHANGED
@@ -8,10 +8,41 @@ As a Ruby Developer, I want to use HandlebarsJS with useful helpers, so that I h
|
|
8
8
|
|
9
9
|
### Stories next on list
|
10
10
|
|
11
|
+
As a Documentor, I can create usage examples for this GEM, so that I can document the project
|
12
|
+
|
13
|
+
- setup rspec-usage for the project
|
14
|
+
- create templates for generating slide decks
|
15
|
+
- record videos on how to use
|
16
|
+
|
17
|
+
As a Developer, I can release a new version of the GEM, so that the updated Gem appears on rubygems and rubydoc
|
18
|
+
|
19
|
+
- research automated solution, eg. rake
|
20
|
+
- implement the solution
|
21
|
+
|
22
|
+
As a Developer, I have flexible and modular formatters, so that I can format data into a new format
|
23
|
+
|
24
|
+
- Define formatter categories, https://github.com/helpers/handlebars-helpers has 20 categories
|
25
|
+
- Create modular formatters with tests
|
26
|
+
|
27
|
+
### Tasks next on list
|
28
|
+
|
29
|
+
add support for misc helper category
|
30
|
+
|
31
|
+
- add noop/raw helper
|
32
|
+
- add safe helper
|
33
|
+
|
34
|
+
add support for category count, helper count and formatter count to readme.md
|
35
|
+
|
36
|
+
## Stories and tasks
|
37
|
+
|
38
|
+
### Stories - completed
|
39
|
+
|
11
40
|
As a Developer, I can easily render Handlebar Templates, so that I am more efficient
|
12
41
|
|
13
42
|
- Build simplified API for rendering templates
|
14
43
|
|
44
|
+
As a Developer, I can have string case formatting helpers, so that I can generate code and documentation using handlebars
|
45
|
+
|
15
46
|
As a Developer, I can alias existing helpers, so that I have helper names that make sense to me
|
16
47
|
|
17
48
|
- Provide a flexible mechanism for template aliases
|
@@ -20,16 +51,23 @@ As a Developer, I can load specific groups of helpers, so that memory consumptio
|
|
20
51
|
|
21
52
|
- Lazy load ruby helpers on an as needed basis
|
22
53
|
|
23
|
-
### Tasks
|
54
|
+
### Tasks - completed
|
24
55
|
|
25
|
-
|
56
|
+
refactor inflections namespace
|
26
57
|
|
27
|
-
-
|
28
|
-
-
|
58
|
+
- Move pluralize and singularize to inflections
|
59
|
+
- Add support for ordinalize case, eg. 1st, 2nd, 3rd, 4th
|
60
|
+
- Add support for ordinal case, eg. st, nd, rd, th
|
29
61
|
|
30
|
-
|
62
|
+
String tokenizer that formats input strings in a consistent fashion
|
31
63
|
|
32
|
-
|
64
|
+
- Setup a single opinionated string tokenizer
|
65
|
+
- Make the string tokenizer configurable so it can be replaced with a different opinionated tokenizer
|
66
|
+
|
67
|
+
Setup RubyGems and RubyDoc
|
68
|
+
|
69
|
+
- Build and deploy gem to [rubygems.org](https://rubygems.org/gems/handlebars-helpers)
|
70
|
+
- Attach documentation to [rubydoc.info](https://rubydoc.info/github/klueless-io/handlebars-helpers/master)
|
33
71
|
|
34
72
|
Setup GitHub Action (test and lint)
|
35
73
|
|
data/handlebars-helpers.gemspec
CHANGED
data/lib/handlebars/helpers.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'handlebars/helpers/configuration'
|
4
|
+
|
5
|
+
module Handlebars
|
6
|
+
module Helpers
|
7
|
+
# base helper provides an interface to wrap your parsing logic
|
8
|
+
# in a Handlebars aware context
|
9
|
+
class BaseHelper
|
10
|
+
# Wrap the parse method in a handlebars context
|
11
|
+
# aware block that is used during registration
|
12
|
+
def handlebars_helper
|
13
|
+
proc { |_context, value| wrapper(parse(value)) }
|
14
|
+
end
|
15
|
+
|
16
|
+
# All child classes will generally implement this method
|
17
|
+
def parse(value)
|
18
|
+
value
|
19
|
+
end
|
20
|
+
|
21
|
+
# If you need to wrap the return value in a specific
|
22
|
+
# Handlebars Type, eg. SafeString, then you can override
|
23
|
+
# this method
|
24
|
+
def wrapper(value)
|
25
|
+
value
|
26
|
+
end
|
27
|
+
|
28
|
+
# String tokenizer will clean up a string so that
|
29
|
+
# all sorts of case formatted strings can be
|
30
|
+
# represented in a consistent fashion
|
31
|
+
def tokenizer
|
32
|
+
@_tokenizer ||= Handlebars::Helpers.configuration.tokenizer
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'handlebars/safe_string'
|
4
|
+
require 'handlebars/helpers/configuration'
|
5
|
+
require 'handlebars/helpers/base_helper'
|
6
|
+
|
7
|
+
module Handlebars
|
8
|
+
module Helpers
|
9
|
+
# base safe string helper provides will return a Handlebars::SafeString
|
10
|
+
# which allows characters like < > " to be rendered as is
|
11
|
+
class BaseSafeStringHelper < BaseHelper
|
12
|
+
def wrapper(value)
|
13
|
+
Handlebars::SafeString.new(value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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
|
+
# Classify: Creates a class name from a plural table name like Rails does for table names to models.
|
13
|
+
class Classify < Handlebars::Helpers::BaseHelper
|
14
|
+
# Parse will create a class name from a plural table name like Rails does for table names to models.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# puts Classify.new.parse('product_categories')
|
19
|
+
#
|
20
|
+
# ProductCategory
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
#
|
24
|
+
# puts Classify.new.parse('product_category')
|
25
|
+
#
|
26
|
+
# ProductCategory
|
27
|
+
#
|
28
|
+
# @param [String] value - name of the ruby class in plural or singular notation
|
29
|
+
# @return [String] value converted to ruby class notation
|
30
|
+
def parse(value)
|
31
|
+
tokenizer.parse(value, separator: '_', forced_separator: true).classify
|
32
|
+
end
|
33
|
+
|
34
|
+
def handlebars_helper
|
35
|
+
proc { |_context, value| wrapper(parse(value)) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -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
|