mirror of https://github.com/abpframework/abp.git
4 changed files with 96 additions and 77 deletions
@ -1,17 +1,8 @@ |
|||
@model Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.Shared.Demos.ButtonsDemo.DemoViewModel |
|||
<div class="abp-theme-demo-section"> |
|||
<h2> |
|||
Basic Buttons |
|||
</h2> |
|||
<div class="abp-theme-demo-section-body"> |
|||
<!-- <DemoSection:Buttons.Basic> --> |
|||
<abp-button button-type="Primary" text="Primary button" /> |
|||
<abp-button button-type="Secondary" text="Secondary button" /> |
|||
<!-- </DemoSection:Buttons.Basic> --> |
|||
</div> |
|||
<div> |
|||
<pre> |
|||
@Model.SourceCodes["Buttons.Basic"] |
|||
</pre> |
|||
</div> |
|||
</div> |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.Shared.Demos.ButtonsDemo |
|||
<h2> |
|||
Basic Buttons |
|||
</h2> |
|||
<abp-demo-section name="Buttons.Basic" view-path="@ButtonsDemoViewComponent.ViewPath"> |
|||
<abp-button button-type="Primary" text="Primary button" /> |
|||
<abp-button button-type="Secondary" text="Secondary button" /> |
|||
</abp-demo-section> |
|||
@ -0,0 +1,84 @@ |
|||
using System; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
using Microsoft.Extensions.FileProviders; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.Shared.TagHelpers |
|||
{ |
|||
public class AbpDemoSectionTagHelper : AbpTagHelper |
|||
{ |
|||
private const string DemoSectionOpeningTag = "<abp-demo-section"; |
|||
private const string DemoSectionClosingTag = "</abp-demo-section"; |
|||
|
|||
public string ViewPath { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
private readonly IVirtualFileProvider _virtualFileProvider; |
|||
|
|||
public AbpDemoSectionTagHelper(IVirtualFileProvider virtualFileProvider) |
|||
{ |
|||
_virtualFileProvider = virtualFileProvider; |
|||
} |
|||
|
|||
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
var content = await output.GetChildContentAsync(); |
|||
|
|||
output.PostContent.AppendHtml("<h3>ABP Tag Helpers</h3>"); |
|||
output.PostContent.AppendHtml("<pre>"); |
|||
output.PostContent.Append(GetRawDemoSource()); |
|||
output.PostContent.AppendHtml("</pre>"); |
|||
output.PostContent.AppendHtml("<hr />"); |
|||
output.PostContent.AppendHtml("<h3>Bootstrap</h3>"); |
|||
output.PostContent.AppendHtml("<pre>"); |
|||
output.PostContent.Append(content.GetContent()); |
|||
output.PostContent.AppendHtml("</pre>"); |
|||
} |
|||
|
|||
private string GetRawDemoSource() |
|||
{ |
|||
var viewFileInfo = _virtualFileProvider.GetFileInfo(ViewPath); |
|||
var viewFileContent = viewFileInfo.ReadAsString(); |
|||
var lines = viewFileContent.SplitToLines(); |
|||
|
|||
StringBuilder sb = null; |
|||
|
|||
foreach (var line in lines) |
|||
{ |
|||
if (line.Contains(DemoSectionOpeningTag)) |
|||
{ |
|||
if (GetName(line) == Name) |
|||
{ |
|||
sb = new StringBuilder(); |
|||
} |
|||
} |
|||
else if (line.Contains(DemoSectionClosingTag, StringComparison.InvariantCultureIgnoreCase)) |
|||
{ |
|||
if (sb == null) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
return sb.ToString(); |
|||
} |
|||
else if (sb != null) |
|||
{ |
|||
sb.AppendLine(line); |
|||
} |
|||
} |
|||
|
|||
return ""; |
|||
} |
|||
|
|||
private string GetName(string line) |
|||
{ |
|||
var str = line.Substring(line.IndexOf("name=\"", StringComparison.OrdinalIgnoreCase) + "name=\"".Length); |
|||
str = str.Left(str.IndexOf("\"", StringComparison.OrdinalIgnoreCase)); |
|||
return str; |
|||
} |
|||
} |
|||
} |
|||
@ -1,4 +1,5 @@ |
|||
@using System.Globalization |
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo |
|||
Loading…
Reference in new issue