Update text templating document.

pull/8673/head
maliming 5 years ago
parent 765d836c75
commit 46fec693f7

@ -84,6 +84,7 @@ public class DemoTemplateDefinitionProvider : TemplateDefinitionProvider
{
context.Add(
new TemplateDefinition("Hello") //template name: "Hello"
.WithRenderEngine(RazorTemplateRendererProvider.ProviderName)
.WithVirtualFilePath(
"/Demos/Hello/Hello.cshtml", //template content path
isInlineLocalized: true
@ -97,6 +98,7 @@ public class DemoTemplateDefinitionProvider : TemplateDefinitionProvider
* `TemplateDefinition` is the class represents a template. Each template must have a unique name (that will be used while you are rendering the template).
* `/Demos/Hello/Hello.cshtml` is the path of the template file.
* `isInlineLocalized` is used to declare if you are using a single template for all languages (`true`) or different templates for each language (`false`). See the Localization section below for more.
* `WithRenderEngine` method is used to set the render engine of the template.
### The Template Base
@ -223,7 +225,9 @@ context.Add(
new TemplateDefinition(
"PasswordReset", //Template name
typeof(DemoResource) //LOCALIZATION RESOURCE
).WithVirtualFilePath(
)
.WithRenderEngine(RazorTemplateRendererProvider.ProviderName)
.WithVirtualFilePath(
"/Demos/PasswordReset/PasswordReset.cshtml", //template content path
isInlineLocalized: true
)
@ -271,6 +275,7 @@ context.Add(
name: "WelcomeEmail",
defaultCultureName: "en"
)
.WithRenderEngine(RazorTemplateRendererProvider.ProviderName)
.WithVirtualFilePath(
"/Demos/WelcomeEmail/Templates", //template content folder
isInlineLocalized: false
@ -333,7 +338,9 @@ context.Add(
new TemplateDefinition(
"EmailLayout",
isLayout: true //SET isLayout!
).WithVirtualFilePath(
)
.WithRenderEngine(RazorTemplateRendererProvider.ProviderName)
.WithVirtualFilePath(
"/Demos/EmailLayout/EmailLayout.cshtml",
isInlineLocalized: true
)
@ -348,7 +355,9 @@ context.Add(
name: "WelcomeEmail",
defaultCultureName: "en",
layout: "EmailLayout" //Set the LAYOUT
).WithVirtualFilePath(
)
.WithRenderEngine(RazorTemplateRendererProvider.ProviderName)
.WithVirtualFilePath(
"/Demos/WelcomeEmail/Templates",
isInlineLocalized: false
)

@ -49,6 +49,7 @@ public class DemoTemplateDefinitionProvider : TemplateDefinitionProvider
"/Demos/Hello/Hello.tpl", //template content path
isInlineLocalized: true
)
.WithRenderEngine(ScribanTemplateRendererProvider.ProviderName)
);
}
}
@ -58,6 +59,7 @@ public class DemoTemplateDefinitionProvider : TemplateDefinitionProvider
* `TemplateDefinition` is the class represents a template. Each template must have a unique name (that will be used while you are rendering the template).
* `/Demos/Hello/Hello.tpl` is the path of the template file.
* `isInlineLocalized` is used to declare if you are using a single template for all languages (`true`) or different templates for each language (`false`). See the Localization section below for more.
* `WithRenderEngine` method is used to set the render engine of the template.
### The Template Content
@ -175,7 +177,9 @@ context.Add(
new TemplateDefinition(
"PasswordReset", //Template name
typeof(DemoResource) //LOCALIZATION RESOURCE
).WithVirtualFilePath(
)
.WithRenderEngine(ScribanTemplateRendererProvider.ProviderName)
.WithVirtualFilePath(
"/Demos/PasswordReset/PasswordReset.tpl", //template content path
isInlineLocalized: true
)
@ -223,6 +227,7 @@ context.Add(
name: "WelcomeEmail",
defaultCultureName: "en"
)
.WithRenderEngine(ScribanTemplateRendererProvider.ProviderName)
.WithVirtualFilePath(
"/Demos/WelcomeEmail/Templates", //template content folder
isInlineLocalized: false
@ -284,7 +289,9 @@ context.Add(
new TemplateDefinition(
"EmailLayout",
isLayout: true //SET isLayout!
).WithVirtualFilePath(
)
.WithRenderEngine(ScribanTemplateRendererProvider.ProviderName)
.WithVirtualFilePath(
"/Demos/EmailLayout/EmailLayout.tpl",
isInlineLocalized: true
)
@ -299,7 +306,9 @@ context.Add(
name: "WelcomeEmail",
defaultCultureName: "en",
layout: "EmailLayout" //Set the LAYOUT
).WithVirtualFilePath(
)
.WithRenderEngine(ScribanTemplateRendererProvider.ProviderName)
.WithVirtualFilePath(
"/Demos/WelcomeEmail/Templates",
isInlineLocalized: false
)

@ -24,6 +24,8 @@ ABP Framework provides two types of engines;
* **[Razor](Text-Templating-Razor.md)**
* **[Scriban](Text-Templating-Scriban.md)**
You can use different template engines at the same time, or even create a new template engine.
## Source Code
Get [the source code of the sample application](https://github.com/abpframework/abp-samples/tree/master/TextTemplateDemo) developed and referred through this document.

Loading…
Cancel
Save