0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-26 02:50:28 +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 result
end 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 end
def build(build_opts = {}, params = {}) def build(build_opts = {}, params = {})