0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00

Add key recursion to wizard field interpolation

Dieser Commit ist enthalten in:
Angus McLeod 2019-08-01 11:05:03 +10:00
Ursprung b41d66214a
Commit b634bed1d0

Datei anzeigen

@ -53,7 +53,13 @@ class CustomWizard::Builder
result
end
result = result.gsub(/w\{(.*?)\}/) { |match| data[$1.to_sym] }
result.gsub(/w\{(.*?)\}/) { |match| recurse(data, [*$1.split('.')]) }
end
def self.recurse(data, keys)
k = keys.shift
result = data[k]
keys.empty? ? result : self.recurse(result, keys)
end
def build(build_opts = {}, params = {})