diff --git a/Htmt/Htmt.csproj b/Htmt/Htmt.csproj
index 8a83a68..e463873 100644
--- a/Htmt/Htmt.csproj
+++ b/Htmt/Htmt.csproj
@@ -6,14 +6,14 @@
enable
Asko Nõmm
Htmt
- 1.2.0
+ 1.2.1
HTML/XML templating library for .NET
html xml template
https://github.com/askonomm/htmt
MIT
https://github.com/askonomm/htmt
git
- Added support for partials, complex conditional expressions and auto-closing of void elements in HTML.
+ Fixed an issue where usage of HTML entities caused Htmt to throw an exception.
README.md
diff --git a/Htmt/Parser.cs b/Htmt/Parser.cs
index 02a149c..0701128 100644
--- a/Htmt/Parser.cs
+++ b/Htmt/Parser.cs
@@ -43,9 +43,10 @@ private void Parse()
RemoveDoctype();
CloseVoidElements();
- TransformHtmlEntities();
}
+ TransformHtmlEntities();
+
var templateStr = $"{Template}";
using var reader = XmlReader.Create(new StringReader(templateStr), _xmlSettings);
Xml.Load(reader);
diff --git a/HtmtTests/AttributeParserTest.cs b/HtmtTests/AttributeParserTest.cs
index a15a12f..03c2312 100644
--- a/HtmtTests/AttributeParserTest.cs
+++ b/HtmtTests/AttributeParserTest.cs
@@ -315,6 +315,18 @@ public void TestInnerPartialAttributeParserWithData()
Assert.AreEqual("
Hello, World!
", html);
}
+
+ [TestMethod]
+ public void TestInnerPartialAttributeParserWithHtmlEntities()
+ {
+ const string template = "";
+ const string partial = "This way →
";
+ var data = new Dictionary { { "partial", partial } };
+ var parser = new Parser { Template = template, Data = data };
+ var html = parser.ToHtml();
+
+ Assert.AreEqual("This way →
", html);
+ }
[TestMethod]
public void TestOuterPartialAttributeParser()
@@ -339,4 +351,16 @@ public void TestOuterPartialAttributeParserWithData()
Assert.AreEqual("Hello, World!
", html);
}
+
+ [TestMethod]
+ public void TestOuterPartialAttributeParserWithHtmlEntities()
+ {
+ const string template = "";
+ const string partial = "This way →
";
+ var data = new Dictionary { { "partial", partial } };
+ var parser = new Parser { Template = template, Data = data };
+ var html = parser.ToHtml();
+
+ Assert.AreEqual("This way →
", html);
+ }
}
\ No newline at end of file
diff --git a/HtmtTests/ParserTest.cs b/HtmtTests/ParserTest.cs
index 9b1820b..26556d1 100644
--- a/HtmtTests/ParserTest.cs
+++ b/HtmtTests/ParserTest.cs
@@ -65,4 +65,13 @@ public void TestHtmlEntities()
Assert.AreEqual("Hello, World!
", parser.ToHtml());
}
+
+ [TestMethod]
+ public void TestMoreHtmlEntities()
+ {
+ const string template = "→";
+ var parser = new Htmt.Parser { Template = template };
+
+ Assert.AreEqual("→", parser.ToHtml());
+ }
}
\ No newline at end of file