Commits vergleichen
2 Commits
main
...
template_p
Autor | SHA1 | Datum | |
---|---|---|---|
|
9c6945be2b | ||
|
c009d780a1 |
3 geänderte Dateien mit 22 neuen und 2 gelöschten Zeilen
|
@ -232,7 +232,12 @@ class CustomWizard::Mapper
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts[:wizard]
|
if opts[:wizard]
|
||||||
string.gsub!(/w\{(.*?)\}/) { |match| recurse(data, [*$1.split('.')]) || '' }
|
string.gsub!(/w\{(.*?)\}/) do |match|
|
||||||
|
content = recurse(data, [*$1.split('.')]) || ''
|
||||||
|
# Curly braces are used by liquid, so they can't be part of the content.
|
||||||
|
# TODO: Ideally these would be escaped somehow.
|
||||||
|
content.gsub(/{/, "(").gsub(/}/, ")") if opts[:template]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts[:value]
|
if opts[:value]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
# name: discourse-custom-wizard
|
# name: discourse-custom-wizard
|
||||||
# about: Create custom wizards
|
# about: Create custom wizards
|
||||||
# version: 1.18.4
|
# version: 1.18.5
|
||||||
# authors: Angus McLeod
|
# authors: Angus McLeod
|
||||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||||
# contact emails: angus@thepavilion.io
|
# contact emails: angus@thepavilion.io
|
||||||
|
|
|
@ -459,5 +459,20 @@ describe CustomWizard::Mapper do
|
||||||
expect(result).to eq("")
|
expect(result).to eq("")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "replaces curly braces in user content with braces" do
|
||||||
|
params_with_curly_braces = {
|
||||||
|
"step_1_field_1" => "Some code with braces {%s}"
|
||||||
|
}
|
||||||
|
template = "w{step_1_field_1}"
|
||||||
|
mapper = create_template_mapper(params_with_curly_braces, user1)
|
||||||
|
result = mapper.interpolate(
|
||||||
|
template.dup,
|
||||||
|
template: true,
|
||||||
|
user: true,
|
||||||
|
wizard: true
|
||||||
|
)
|
||||||
|
expect(result).to eq("Some code with braces (%s)")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren