0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00

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
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
def self.recurse(data, keys)