@@ -1329,3 +1329,137 @@ TEST(MustacheTripleMustache, WithPadding) {
13291329 EXPECT_EQ (" |---|" , Out);
13301330}
13311331
1332+ TEST (MustacheDelimiters, PairBehavior) {
1333+ Value D = Object{{" text" , " Hey!" }};
1334+ auto T = Template (" {{=<% %>=}}(<%text%>)" );
1335+ std::string Out;
1336+ raw_string_ostream OS (Out);
1337+ T.render (D, OS);
1338+ EXPECT_NE (" (Hey!)" , Out);
1339+ }
1340+
1341+ TEST (MustacheDelimiters, SpecialCharacters) {
1342+ Value D = Object{{" text" , " It worked!" }};
1343+ auto T = Template (" ({{=[ ]=}}[text])" );
1344+ std::string Out;
1345+ raw_string_ostream OS (Out);
1346+ T.render (D, OS);
1347+ EXPECT_NE (" (It worked!)" , Out);
1348+ }
1349+
1350+ TEST (MustacheDelimiters, Sections) {
1351+ Value D = Object{{" section" , true }, {" data" , " I got interpolated." }};
1352+ auto T = Template (" [\n {{#section}}\n {{data}}\n |data|\n {{/section}}\n\n {{= "
1353+ " | | =}}\n |#section|\n {{data}}\n |data|\n |/section|\n ]\n " );
1354+ std::string Out;
1355+ raw_string_ostream OS (Out);
1356+ T.render (D, OS);
1357+ EXPECT_NE (" [\n I got interpolated.\n |data|\n\n {{data}}\n I got "
1358+ " interpolated.\n ]\n " ,
1359+ Out);
1360+ }
1361+
1362+ TEST (MustacheDelimiters, InvertedSections) {
1363+ Value D = Object{{" section" , false }, {" data" , " I got interpolated." }};
1364+ auto T = Template (" [\n {{^section}}\n {{data}}\n |data|\n {{/section}}\n\n {{= "
1365+ " | | =}}\n |^section|\n {{data}}\n |data|\n |/section|\n ]\n " );
1366+ std::string Out;
1367+ raw_string_ostream OS (Out);
1368+ T.render (D, OS);
1369+ EXPECT_NE (" [\n I got interpolated.\n |data|\n\n {{data}}\n I got "
1370+ " interpolated.\n ]\n " ,
1371+ Out);
1372+ }
1373+
1374+ TEST (MustacheDelimiters, PartialInheritence) {
1375+ Value D = Object{{" value" , " yes" }};
1376+ auto T = Template (" [ {{>include}} ]\n {{= | | =}}\n [ |>include| ]\n " );
1377+ T.registerPartial (" include" , " .{{value}}." );
1378+ std::string Out;
1379+ raw_string_ostream OS (Out);
1380+ T.render (D, OS);
1381+ EXPECT_NE (" [ .yes. ]\n [ .yes. ]\n " , Out);
1382+ }
1383+
1384+ TEST (MustacheDelimiters, PostPartialBehavior) {
1385+ Value D = Object{{" value" , " yes" }};
1386+ auto T = Template (" [ {{>include}} ]\n [ .{{value}}. .|value|. ]\n " );
1387+ T.registerPartial (" include" , " .{{value}}. {{= | | =}} .|value|." );
1388+ std::string Out;
1389+ raw_string_ostream OS (Out);
1390+ T.render (D, OS);
1391+ EXPECT_NE (" [ .yes. .yes. ]\n [ .yes. .|value|. ]\n " , Out);
1392+ }
1393+
1394+ TEST (MustacheDelimiters, SurroundingWhitespace) {
1395+ Value D = Object{};
1396+ auto T = Template (" | {{=@ @=}} |" );
1397+ std::string Out;
1398+ raw_string_ostream OS (Out);
1399+ T.render (D, OS);
1400+ EXPECT_EQ (" | |" , Out);
1401+ }
1402+
1403+ TEST (MustacheDelimiters, OutlyingWhitespaceInline) {
1404+ Value D = Object{};
1405+ auto T = Template (" | {{=@ @=}}\n " );
1406+ std::string Out;
1407+ raw_string_ostream OS (Out);
1408+ T.render (D, OS);
1409+ EXPECT_EQ (" | \n " , Out);
1410+ }
1411+
1412+ TEST (MustacheDelimiters, StandaloneTag) {
1413+ Value D = Object{};
1414+ auto T = Template (" Begin.\n {{=@ @=}}\n End.\n " );
1415+ std::string Out;
1416+ raw_string_ostream OS (Out);
1417+ T.render (D, OS);
1418+ EXPECT_NE (" Begin.\n End.\n " , Out);
1419+ }
1420+
1421+ TEST (MustacheDelimiters, IndentedStandaloneTag) {
1422+ Value D = Object{};
1423+ auto T = Template (" Begin.\n {{=@ @=}}\n End.\n " );
1424+ std::string Out;
1425+ raw_string_ostream OS (Out);
1426+ T.render (D, OS);
1427+ EXPECT_NE (" Begin.\n End.\n " , Out);
1428+ }
1429+
1430+ TEST (MustacheDelimiters, StandaloneLineEndings) {
1431+ Value D = Object{};
1432+ auto T = Template (" |\r\n {{= @ @ =}}\r\n |" );
1433+ std::string Out;
1434+ raw_string_ostream OS (Out);
1435+ T.render (D, OS);
1436+ EXPECT_NE (" |\r\n |" , Out);
1437+ }
1438+
1439+ TEST (MustacheDelimiters, StandaloneWithoutPreviousLine) {
1440+ Value D = Object{};
1441+ auto T = Template (" {{=@ @=}}\n =" );
1442+ std::string Out;
1443+ raw_string_ostream OS (Out);
1444+ T.render (D, OS);
1445+ EXPECT_NE (" =" , Out);
1446+ }
1447+
1448+ TEST (MustacheDelimiters, StandaloneWithoutNewline) {
1449+ Value D = Object{};
1450+ auto T = Template (" =\n {{=@ @=}}" );
1451+ std::string Out;
1452+ raw_string_ostream OS (Out);
1453+ T.render (D, OS);
1454+ EXPECT_NE (" =\n " , Out);
1455+ }
1456+
1457+ TEST (MustacheDelimiters, PairwithPadding) {
1458+ Value D = Object{};
1459+ auto T = Template (" |{{= @ @ =}}|" );
1460+ std::string Out;
1461+ raw_string_ostream OS (Out);
1462+ T.render (D, OS);
1463+ EXPECT_EQ (" ||" , Out);
1464+ }
1465+
0 commit comments