bug #3154: Fix issues when the template contains single quotes
(cherry picked from commit 91edfb688f6480f54aac1bf20a881436d2014d92)