0

I just upgraded from smart.format 2.4.2 to 2.5.0. I have the following in production since 2018:

attFilePath = "C:/dev/template.html" //HTML TEMPLATE WITH PLACEHOLDERS IN IT LIKE, Welcome {FirstName})
Smart.Default.Parser.UseAlternativeEscapeChar('\\');
var myTemplate = File.ReadAllText(attFilePath); 
request.AddParameter(emailMessage.MessageIsBodyHtml ? "html" : "text", Smart.Format(File.ReadAllText(attFilePath), passengerTemplateValues));

The last instruction reads the html as a string and apply smart.format to change the placeholders with the actual data. Everything worked fine until I decide to upgrade to 2.5. The error that I'm getting is "There are 56 issues, Invalid character in the selector". What Actually change that it cannot parse the html with the placeholders anymore? I change to 2.4.2 and everything is working now again.

Ray
  • 483
  • 4
  • 17
  • 1
    Please provide a [mre] in the form of a template that causes the error with 2.5.0, but not with 2.4.2, with the code you've already provided. Also, take a look at the [change log](https://github.com/axuno/SmartFormat/blob/master/CHANGES.md) and see if any of the changes mentioned there, especially the *breaking changes*, might be related to that error. – madreflection Jan 22 '20 at 02:51

2 Answers2

0

While processing pure HTML works absolutely fine, the result becomes unpredictable with CSS and/or JavaScript. The reason is: Smart.Format uses braces to identify Placeholders, which are at the same time part of the CSS/JavaScript notation. There is a solution published in the Smart.Format Wiki

axuno
  • 581
  • 4
  • 15
-2

Change Log breaking changes help with the problem! Must read first!

Ray
  • 483
  • 4
  • 17