@@ -1335,11 +1335,12 @@ public void TestWithBaseTemplateModelWithDisplayNames()
1335
1335
1336
1336
MainDocumentPart mainPart = wpDocument . AddMainDocumentPart ( ) ;
1337
1337
mainPart . Document = new Document ( new Body ( new Paragraph (
1338
- new Run ( new Text ( "{{ds.MyString }} + {{ds.SomeNumber }}" ) )
1338
+ new Run ( new Text ( "{{ds.Vorname }} {{ds.LastName}} aus {{ds.Anschrift }}" ) )
1339
1339
) ) ) ;
1340
1340
wpDocument . Save ( ) ;
1341
1341
memStream . Position = 0 ;
1342
1342
var docTemplate = new DocxTemplate ( memStream ) ;
1343
+ docTemplate . RegisterFormatter ( new Markdown . MarkdownFormatter ( ) ) ;
1343
1344
docTemplate . BindModel ( "ds" , new DummyModelWithDisplayNames ( ) ) ;
1344
1345
var result = docTemplate . Process ( ) ;
1345
1346
docTemplate . Validate ( ) ;
@@ -1348,7 +1349,7 @@ public void TestWithBaseTemplateModelWithDisplayNames()
1348
1349
1349
1350
var document = WordprocessingDocument . Open ( result , false ) ;
1350
1351
var body = document . MainDocumentPart . Document . Body ;
1351
- Assert . That ( body . InnerText , Is . EqualTo ( "Hello World! + 42 " ) ) ;
1352
+ Assert . That ( body . InnerText , Is . EqualTo ( "John Doe aus Musterstraße 42, A-4242 Musterhausen " ) ) ;
1352
1353
}
1353
1354
1354
1355
private static DriveStudentOverviewReportingModel CrateBillTemplate2Model ( )
@@ -1520,10 +1521,14 @@ public bool TryGetPropertyValue(string propertyName, out ValueWithMetadata value
1520
1521
1521
1522
private class DummyModelWithDisplayNames : TemplateModelWithDisplayNames
1522
1523
{
1523
- [ DisplayName ( "MyString" ) ]
1524
- public string SomeString { get ; set ; } = "Hello World!" ;
1524
+ [ DisplayName ( "Vorname" ) ]
1525
+ public string FirstName { get ; set ; } = "John" ;
1526
+
1527
+ public string LastName { get ; set ; } = "Doe" ;
1525
1528
1526
- public int SomeNumber { get ; set ; } = 42 ;
1529
+ [ DisplayName ( "Anschrift" ) ]
1530
+ [ ModelProperty ( DefaultFormatter = "md" ) ]
1531
+ public string Address { get ; set ; } = "Musterstraße 42, **A-4242 Musterhausen**" ;
1527
1532
}
1528
1533
}
1529
1534
}
0 commit comments