forked from abpframework/abp-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
118 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
{{content}} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A global object value: {{myGlobalObject}} |
31 changes: 31 additions & 0 deletions
31
TextTemplateDemo/Demos/GlobalContext/GlobalContextUsageDemo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Volo.Abp.DependencyInjection; | ||
using Volo.Abp.TextTemplating; | ||
|
||
namespace TextTemplateDemo.Demos.GlobalContext | ||
{ | ||
public class GlobalContextUsageDemo : ITransientDependency | ||
{ | ||
private readonly ITemplateRenderer _templateRenderer; | ||
|
||
public GlobalContextUsageDemo(ITemplateRenderer templateRenderer) | ||
{ | ||
_templateRenderer = templateRenderer; | ||
} | ||
|
||
public async Task RunAsync() | ||
{ | ||
var result = await _templateRenderer.RenderAsync( | ||
"GlobalContextUsage", | ||
globalContext: new Dictionary<string, object> | ||
{ | ||
{"myGlobalObject", "TEST VALUE"} | ||
} | ||
); | ||
|
||
Console.WriteLine(result); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
TextTemplateDemo/Demos/TemplateContent/TemplateContentDemo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Volo.Abp.DependencyInjection; | ||
using Volo.Abp.TextTemplating; | ||
|
||
namespace TextTemplateDemo.Demos.TemplateContent | ||
{ | ||
public class TemplateContentDemo : ITransientDependency | ||
{ | ||
private readonly ITemplateContentProvider _templateContentProvider; | ||
|
||
public TemplateContentDemo(ITemplateContentProvider templateContentProvider) | ||
{ | ||
_templateContentProvider = templateContentProvider; | ||
} | ||
|
||
public async Task RunAsync() | ||
{ | ||
var result = await _templateContentProvider | ||
.GetContentOrNullAsync("Hello"); | ||
|
||
Console.WriteLine(result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Threading.Tasks; | ||
using Volo.Abp.DependencyInjection; | ||
using Volo.Abp.TextTemplating; | ||
|
||
namespace TextTemplateDemo.Other | ||
{ | ||
public class MyTemplateContentProvider : ITemplateContentContributor, ITransientDependency | ||
{ | ||
public async Task<string> GetOrNullAsync(TemplateContentContributorContext context) | ||
{ | ||
var templateName = context.TemplateDefinition.Name; | ||
|
||
//TODO: Try to find content from another source | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters