1
0
Fork 0

Commits vergleichen

...

2 Commits

Autor SHA1 Nachricht Datum
Angus McLeod
9c6945be2b Bump version 2022-04-29 12:22:29 +02:00
Angus McLeod
c009d780a1 Replace curly braces with braces in user entered content 2022-04-29 12:18:47 +02:00
3 geänderte Dateien mit 22 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -232,7 +232,12 @@ class CustomWizard::Mapper
end
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
if opts[:value]

Datei anzeigen

@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-custom-wizard
# about: Create custom wizards
# version: 1.18.4
# version: 1.18.5
# authors: Angus McLeod
# url: https://github.com/paviliondev/discourse-custom-wizard
# contact emails: angus@thepavilion.io

Datei anzeigen

@ -459,5 +459,20 @@ describe CustomWizard::Mapper do
expect(result).to eq("")
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