Class: Handlebars::Helpers::StringFormatting::Surround
- Inherits:
-
BaseSafeStringHelper
- Object
- BaseHelper
- BaseSafeStringHelper
- Handlebars::Helpers::StringFormatting::Surround
- Defined in:
- lib/handlebars/helpers/string_formatting/surround.rb
Overview
Surround will surround a value with prefix and suffix, an empty value is considered valid data
Instance Method Summary collapse
- #handlebars_helper ⇒ Object
-
#parse(value, prefix, suffix, formats) ⇒ String
Parse will surround a value with prefix and suffix, an empty value is considered valid data.
Methods inherited from BaseSafeStringHelper
Methods inherited from BaseHelper
#parse_json, #struct_to_hash, #tokenizer, #wrapper
Instance Method Details
#handlebars_helper ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/handlebars/helpers/string_formatting/surround.rb', line 39 def proc do |_context, value, prefix, suffix, formats| # Handle optional: formats formats = nil if formats.is_a?(V8::Object) wrapper(parse(value, prefix, suffix, formats)) end end |
#parse(value, prefix, suffix, formats) ⇒ String
Parse will surround a value with prefix and suffix, an empty value is considered valid data
34 35 36 37 |
# File 'lib/handlebars/helpers/string_formatting/surround.rb', line 34 def parse(value, prefix, suffix, formats) format_as = ::Helpers::StringFormatting::FormatAs.new "#{prefix}#{format_as.parse(value, formats)}#{suffix}" end |