-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
OSOE-837: Support localized HTML strings in Lombiq.VueJs
- Loading branch information
Showing
8 changed files
with
204 additions
and
17 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
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,22 @@ | ||
using OrchardCore.DisplayManagement.Implementation; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lombiq.VueJs.Services; | ||
|
||
/// <summary> | ||
/// A service that handles <c>[[{name} input ]]</c> expressions in Vue SFC templates. Used by <see | ||
/// cref="VueSingleFileComponentShapeTemplateViewEngine"/>. | ||
/// </summary> | ||
public interface IVueTemplateExpressionConverter | ||
{ | ||
/// <summary> | ||
/// Returns a value indicating whether this converter should handle the provided <paramref name="input"/>, typically | ||
/// based on the <paramref name="name"/>. | ||
/// </summary> | ||
bool IsApplicable(string name, string input, DisplayContext displayContext); | ||
|
||
/// <summary> | ||
/// Returns the output that should be substituted instead of the provided expression. | ||
/// </summary> | ||
ValueTask<string> ConvertAsync(string name, string input, DisplayContext displayContext); | ||
} |
24 changes: 24 additions & 0 deletions
24
Lombiq.VueJs/Services/LiquidVueTemplateExpressionConverter.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,24 @@ | ||
using Fluid; | ||
using OrchardCore.DisplayManagement.Implementation; | ||
using OrchardCore.Liquid; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lombiq.VueJs.Services; | ||
|
||
public class LiquidVueTemplateExpressionConverter : IVueTemplateExpressionConverter | ||
{ | ||
private readonly ILiquidTemplateManager _liquidTemplateManager; | ||
|
||
public LiquidVueTemplateExpressionConverter(ILiquidTemplateManager liquidTemplateManager) => | ||
_liquidTemplateManager = liquidTemplateManager; | ||
|
||
public bool IsApplicable(string name, string input, DisplayContext displayContext) => | ||
"liquid".EqualsOrdinalIgnoreCase(name); | ||
|
||
public async ValueTask<string> ConvertAsync(string name, string input, DisplayContext displayContext) => | ||
await _liquidTemplateManager.RenderStringAsync( | ||
input, | ||
NullEncoder.Default, | ||
displayContext); | ||
} |
20 changes: 20 additions & 0 deletions
20
Lombiq.VueJs/Services/MarkdownVueTemplateExpressionConverter.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,20 @@ | ||
using OrchardCore.DisplayManagement.Implementation; | ||
using OrchardCore.Markdown.Services; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lombiq.VueJs.Services; | ||
|
||
public class MarkdownVueTemplateExpressionConverter : IVueTemplateExpressionConverter | ||
{ | ||
private readonly IMarkdownService _markdownService; | ||
|
||
public MarkdownVueTemplateExpressionConverter(IMarkdownService markdownService) => | ||
_markdownService = markdownService; | ||
|
||
public bool IsApplicable(string name, string input, DisplayContext displayContext) => | ||
"markdown".EqualsOrdinalIgnoreCase(name); | ||
|
||
public ValueTask<string> ConvertAsync(string name, string input, DisplayContext displayContext) => | ||
ValueTask.FromResult(_markdownService.ToHtml(input)); | ||
} |
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
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