1
0
Fork 0

Add support for date variable in field interpolation

Dieser Commit ist enthalten in:
Angus McLeod 2019-09-11 19:53:51 +10:00
Ursprung 83b49a9082
Commit 0b9abf84cc

Datei anzeigen

@ -53,7 +53,21 @@ class CustomWizard::Builder
result result
end end
result.gsub(/w\{(.*?)\}/) { |match| recurse(data, [*$1.split('.')]) } result = result.gsub(/w\{(.*?)\}/) { |match| recurse(data, [*$1.split('.')]) }
result.gsub(/v\{(.*?)\}/) do |match|
attrs = $1.split(':')
key = attrs.first
format = attrs.length > 1 ? attrs.last : nil
v = nil
if key == 'time'
time_format = format.present? ? format : "%B %-d, %Y"
v = Time.now.strftime(time_format)
end
v
end
end end
def self.recurse(data, keys) def self.recurse(data, keys)