Class: Nero::FormatTag

Inherits:
BaseTag show all
Defined in:
lib/nero/format_tag.rb

Instance Method Summary collapse

Instance Method Details

#resolve(args, context:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/nero/format_tag.rb', line 5

def resolve(args, context:)
  template = args[0]
  opts = args.each_with_object({}) do |arg, h|
    h.merge!(arg.transform_keys(&:to_sym)) if arg.is_a?(Hash)
  end
  format(template, opts)
rescue KeyError => e
  context.add_error("format error: #{e.message}")
  nil
end