fix: Stop processing broken liquid tags (#6236)

This commit is contained in:
Sojan Jose
2023-01-11 17:41:02 +05:30
committed by GitHub
parent 98eb20d600
commit ad782e450e
2 changed files with 8 additions and 0 deletions

View File

@@ -26,6 +26,8 @@ module Liquidable
template = Liquid::Template.parse(modified_liquid_content)
self.content = template.render(message_drops)
rescue Liquid::Error
# If there is an error in the liquid syntax, we don't want to process it
end
def modified_liquid_content

View File

@@ -36,6 +36,12 @@ shared_examples_for 'liqudable' do
expect(message.content).to eq 'Can we send you an email at ?'
end
it 'will skip processing broken liquid tags' do
message.content = 'Can we send you an email at {{contact.email} {{hi}} ?'
message.save!
expect(message.content).to eq 'Can we send you an email at {{contact.email} {{hi}} ?'
end
it 'will not process liquid tags in multiple code blocks' do
message.content = 'hey {{contact.name}} how are you? ```code: {{contact.name}}``` ``` code: {{contact.name}} ``` test `{{contact.name}}`'
message.save!