mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 07:13:58 -05:00
Fix color code tag helper not being loaded
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
<ApplicationIcon />
|
||||
<StartupObject />
|
||||
<PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId>
|
||||
<Version>2.2.3</Version>
|
||||
<Version>2.2.4</Version>
|
||||
<Authors>RaidMax</Authors>
|
||||
<Company>Forever None</Company>
|
||||
<Configurations>Debug;Release;Prerelease</Configurations>
|
||||
@ -20,6 +20,8 @@
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<Description>Shared Library for IW4MAdmin</Description>
|
||||
<AssemblyVersion>2.2.4.0</AssemblyVersion>
|
||||
<FileVersion>2.2.4.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'">
|
||||
|
42
SharedLibraryCore/TagHelpers/ColorCode.cs
Normal file
42
SharedLibraryCore/TagHelpers/ColorCode.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SharedLibraryCore
|
||||
{
|
||||
[HtmlTargetElement("color-code")]
|
||||
public class ColorCode : TagHelper
|
||||
{
|
||||
public string Value { get; set; }
|
||||
|
||||
public bool Allow { get; set; } = false;
|
||||
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
output.TagName = "ColorCode";
|
||||
output.TagMode = TagMode.StartTagAndEndTag;
|
||||
|
||||
if (Allow)
|
||||
{
|
||||
var matches = Regex.Matches(Value, @"\^([0-9]|\:)([^\^]*)");
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
char colorCode = match.Groups[1].ToString().Last();
|
||||
output.PreContent.AppendHtml($"<span class='text-color-code-{(colorCode >= 48 && colorCode <= 57 ? colorCode.ToString() : ((int)colorCode).ToString())}'>");
|
||||
output.PreContent.Append(match.Groups[2].ToString());
|
||||
output.PreContent.AppendHtml("</span>");
|
||||
}
|
||||
|
||||
if (matches.Count <= 1)
|
||||
{
|
||||
output.PreContent.SetContent(Value.StripColors());
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
output.PreContent.SetContent(Value.StripColors());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user