-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/HtmlHelpers' into develop
- Loading branch information
Showing
10 changed files
with
223 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
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
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,57 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Umbraco.ModelsBuilder.Embedded v9.0.0-rc001+4f06c1f33a54daf4752a439778626202960db68c | ||
// | ||
// Changes to this file will be lost if the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
using System; | ||
using System.Linq.Expressions; | ||
using Umbraco.Cms.Core.Models.PublishedContent; | ||
using Umbraco.Cms.Core.PublishedCache; | ||
using Umbraco.Cms.Infrastructure.ModelsBuilder; | ||
using Umbraco.Cms.Core; | ||
using Umbraco.Extensions; | ||
|
||
namespace Umbraco.Cms.Web.Common.PublishedModels | ||
{ | ||
/// <summary>UmbNav</summary> | ||
[PublishedModel("umbNav")] | ||
public partial class UmbNav : PublishedContentModel | ||
{ | ||
// helpers | ||
#pragma warning disable 0109 // new is redundant | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-rc001+4f06c1f33a54daf4752a439778626202960db68c")] | ||
public new const string ModelTypeAlias = "umbNav"; | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-rc001+4f06c1f33a54daf4752a439778626202960db68c")] | ||
public new const PublishedItemType ModelItemType = PublishedItemType.Content; | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-rc001+4f06c1f33a54daf4752a439778626202960db68c")] | ||
public new static IPublishedContentType GetModelContentType(IPublishedSnapshotAccessor publishedSnapshotAccessor) | ||
=> PublishedModelUtility.GetModelContentType(publishedSnapshotAccessor, ModelItemType, ModelTypeAlias); | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-rc001+4f06c1f33a54daf4752a439778626202960db68c")] | ||
public static IPublishedPropertyType GetModelPropertyType<TValue>(IPublishedSnapshotAccessor publishedSnapshotAccessor, Expression<Func<UmbNav, TValue>> selector) | ||
=> PublishedModelUtility.GetModelPropertyType(GetModelContentType(publishedSnapshotAccessor), selector); | ||
#pragma warning restore 0109 | ||
|
||
private IPublishedValueFallback _publishedValueFallback; | ||
|
||
// ctor | ||
public UmbNav(IPublishedContent content, IPublishedValueFallback publishedValueFallback) | ||
: base(content, publishedValueFallback) | ||
{ | ||
_publishedValueFallback = publishedValueFallback; | ||
} | ||
|
||
// properties | ||
|
||
///<summary> | ||
/// UmbNavPE | ||
///</summary> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "9.0.0-rc001+4f06c1f33a54daf4752a439778626202960db68c")] | ||
[ImplementPropertyType("umbNavPE")] | ||
public virtual global::System.Collections.Generic.IEnumerable<global::UmbNav.Core.Models.UmbNavItem> UmbNavPE => this.Value<global::System.Collections.Generic.IEnumerable<global::UmbNav.Core.Models.UmbNavItem>>(_publishedValueFallback, "umbNavPE"); | ||
} | ||
} |
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,68 @@ | ||
#if NETCOREAPP | ||
using System.Collections.Generic; | ||
using Microsoft.AspNetCore.Razor.TagHelpers; | ||
using UmbNav.Core.Extensions; | ||
using UmbNav.Core.Models; | ||
using Umbraco.Cms.Core.Models.PublishedContent; | ||
|
||
namespace UmbNav.Core.TagHelpers | ||
{ | ||
public class UmbnavitemTagHelper : TagHelper | ||
{ | ||
public UmbNavItem MenuItem { get; set; } | ||
public UrlMode Mode { get; set; } | ||
public string Culture { get; set; } | ||
|
||
public override void Process(TagHelperContext context, TagHelperOutput output) | ||
{ | ||
output.TagName = "a"; | ||
output.Attributes.SetAttribute("href", MenuItem.Url(Culture, Mode)); | ||
output.Content.SetContent(MenuItem.Title); | ||
|
||
if (!string.IsNullOrEmpty(MenuItem.Target)) | ||
{ | ||
output.Attributes.SetAttribute("target", MenuItem.Target); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(MenuItem.Noopener) || !string.IsNullOrEmpty(MenuItem.Noreferrer)) | ||
{ | ||
var rel = new List<string>(); | ||
|
||
if (!string.IsNullOrEmpty(MenuItem.Noopener)) | ||
{ | ||
rel.Add(MenuItem.Noopener); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(MenuItem.Noreferrer)) | ||
{ | ||
rel.Add(MenuItem.Noreferrer); | ||
} | ||
|
||
if (output.Attributes["rel"] != null) | ||
{ | ||
var originalRelValue = output.Attributes["rel"].Value; | ||
output.Attributes.SetAttribute("rel", string.Format("{0} {1}", originalRelValue, string.Join(" ", rel))); | ||
} | ||
else | ||
{ | ||
output.Attributes.SetAttribute("rel", string.Join(" ", rel)); | ||
} | ||
} | ||
|
||
if (!string.IsNullOrEmpty(MenuItem.CustomClasses)) | ||
{ | ||
if (output.Attributes["class"] != null) | ||
{ | ||
var originalRelValue = output.Attributes["class"].Value; | ||
output.Attributes.SetAttribute("class", string.Format("{0} {1}", originalRelValue, string.Join(" ", MenuItem.CustomClasses))); | ||
} | ||
else | ||
{ | ||
output.Attributes.SetAttribute("rel", string.Join(" ", MenuItem.CustomClasses)); | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
#endif |
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