From 7fcf3210a1294ab0fa25e20119f548de3dd574be Mon Sep 17 00:00:00 2001 From: iJungleboy Date: Thu, 4 Apr 2019 11:27:38 +0200 Subject: [PATCH] miro and docs --- .../HtmlTagsTests/{HrBr.cs => HrBrTests.cs} | 5 ++-- .../Tests for RazorBlade.csproj | 2 +- Razor.Blade/Blade/HtmlTags/Basic/Hr.cs | 4 +--- Razor.Blade/Blade/HtmlTags/Core/ChildTags.cs | 5 +++- Razor.Blade/Blade/HtmlTags/Core/TagOptions.cs | 6 +---- .../Blade/HtmlTags/{Head.cs => Head/Icon.cs} | 20 ---------------- Razor.Blade/Blade/HtmlTags/Head/Meta.cs | 23 +++++++++++++++++++ Razor.Blade/Blade/HtmlTags/Script.cs | 1 + Razor.Blade/Razor.Blade.csproj.DotSettings | 1 + docs/htmltags.md | 8 +++++++ 10 files changed, 42 insertions(+), 33 deletions(-) rename Razor Blades Tests/HtmlTagsTests/{HrBr.cs => HrBrTests.cs} (78%) rename Razor.Blade/Blade/HtmlTags/{Head.cs => Head/Icon.cs} (83%) create mode 100644 Razor.Blade/Blade/HtmlTags/Head/Meta.cs diff --git a/Razor Blades Tests/HtmlTagsTests/HrBr.cs b/Razor Blades Tests/HtmlTagsTests/HrBrTests.cs similarity index 78% rename from Razor Blades Tests/HtmlTagsTests/HrBr.cs rename to Razor Blades Tests/HtmlTagsTests/HrBrTests.cs index fe2710b..ed068cd 100644 --- a/Razor Blades Tests/HtmlTagsTests/HrBr.cs +++ b/Razor Blades Tests/HtmlTagsTests/HrBrTests.cs @@ -1,11 +1,10 @@ -using System; -using Connect.Razor.Blade.HtmlTags; +using Connect.Razor.Blade.HtmlTags; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Razor_Blades_Tests.HtmlTagsTests { [TestClass] - public class HrBr: TagTestBase + public class HrBrTests: TagTestBase { [TestMethod] public void Hr() diff --git a/Razor Blades Tests/Tests for RazorBlade.csproj b/Razor Blades Tests/Tests for RazorBlade.csproj index 04f7079..e4d86c3 100644 --- a/Razor Blades Tests/Tests for RazorBlade.csproj +++ b/Razor Blades Tests/Tests for RazorBlade.csproj @@ -55,7 +55,7 @@ - + diff --git a/Razor.Blade/Blade/HtmlTags/Basic/Hr.cs b/Razor.Blade/Blade/HtmlTags/Basic/Hr.cs index 8c6c8d0..9126710 100644 --- a/Razor.Blade/Blade/HtmlTags/Basic/Hr.cs +++ b/Razor.Blade/Blade/HtmlTags/Basic/Hr.cs @@ -2,8 +2,6 @@ { public class Hr : Tag { - public Hr(string content = null) : base("hr", content, - new TagOptions { Close = false }) - { } + public Hr(string content = null) : base("hr", content, new TagOptions { Close = false }) { } } } diff --git a/Razor.Blade/Blade/HtmlTags/Core/ChildTags.cs b/Razor.Blade/Blade/HtmlTags/Core/ChildTags.cs index 01fe65c..bdb5e22 100644 --- a/Razor.Blade/Blade/HtmlTags/Core/ChildTags.cs +++ b/Razor.Blade/Blade/HtmlTags/Core/ChildTags.cs @@ -7,7 +7,10 @@ public class ChildTags: List { public void Add(object child) { - base.Add(Tag.EnsureTag(child)); + if (child is ChildTags list) + AddRange(list); + else + base.Add(Tag.EnsureTag(child)); } public void Replace(object child) diff --git a/Razor.Blade/Blade/HtmlTags/Core/TagOptions.cs b/Razor.Blade/Blade/HtmlTags/Core/TagOptions.cs index c2767f3..e54c4ea 100644 --- a/Razor.Blade/Blade/HtmlTags/Core/TagOptions.cs +++ b/Razor.Blade/Blade/HtmlTags/Core/TagOptions.cs @@ -4,15 +4,11 @@ public class TagOptions { public const bool DefaultClose = true; public const bool DefaultSelfCloseIfNoContent = false; - //public const string DefaultTagSeparator = "\n"; - //public const string DefaultTextSeparator = ""; + public bool Close { get; set; } = DefaultClose; public bool SelfClose { get; set; } = DefaultSelfCloseIfNoContent; - //public string TagSeparator { get; set; }= DefaultTagSeparator; - //public string TextSeparator { get; set; } = DefaultTextSeparator; - private AttributeOptions _attribute; public AttributeOptions Attribute => _attribute ?? (_attribute = new AttributeOptions()); diff --git a/Razor.Blade/Blade/HtmlTags/Head.cs b/Razor.Blade/Blade/HtmlTags/Head/Icon.cs similarity index 83% rename from Razor.Blade/Blade/HtmlTags/Head.cs rename to Razor.Blade/Blade/HtmlTags/Head/Icon.cs index 33a2cd7..ca2cace 100644 --- a/Razor.Blade/Blade/HtmlTags/Head.cs +++ b/Razor.Blade/Blade/HtmlTags/Head/Icon.cs @@ -3,26 +3,6 @@ namespace Connect.Razor.Blade.HtmlTags { - public class Meta : Tag - { - public Meta(): base("meta", new TagOptions { SelfClose = true }) { } - - public Meta(string name, string content) : this() - { - Attr("name", name); - Attr("content", content); - } - } - - public class MetaOg : Meta - { - public MetaOg(string property, string content) : base() - { - Attr( "property", property); - Attr("content", content); - } - } - public class Icon : Tag { internal const int SizeUndefined = 0; diff --git a/Razor.Blade/Blade/HtmlTags/Head/Meta.cs b/Razor.Blade/Blade/HtmlTags/Head/Meta.cs new file mode 100644 index 0000000..9b4e85d --- /dev/null +++ b/Razor.Blade/Blade/HtmlTags/Head/Meta.cs @@ -0,0 +1,23 @@ +namespace Connect.Razor.Blade.HtmlTags +{ + public class Meta : Tag + { + public Meta(): base("meta", new TagOptions { SelfClose = true }) { } + + public Meta(string name, string content) : this() + { + Attr("name", name); + Attr("content", content); + } + } + + public class MetaOg : Meta + { + public MetaOg(string property, string content) + { + Attr("property", property); + Attr("content", content); + } + } + +} diff --git a/Razor.Blade/Blade/HtmlTags/Script.cs b/Razor.Blade/Blade/HtmlTags/Script.cs index 9fe7962..84ca688 100644 --- a/Razor.Blade/Blade/HtmlTags/Script.cs +++ b/Razor.Blade/Blade/HtmlTags/Script.cs @@ -4,6 +4,7 @@ namespace Connect.Razor.Blade.HtmlTags { public class Script: Tag { + // todo! public Script() : base("script") { diff --git a/Razor.Blade/Razor.Blade.csproj.DotSettings b/Razor.Blade/Razor.Blade.csproj.DotSettings index 14aef78..b897228 100644 --- a/Razor.Blade/Razor.Blade.csproj.DotSettings +++ b/Razor.Blade/Razor.Blade.csproj.DotSettings @@ -2,6 +2,7 @@ True True True + True True False True diff --git a/docs/htmltags.md b/docs/htmltags.md index 51da53c..c7740f4 100644 --- a/docs/htmltags.md +++ b/docs/htmltags.md @@ -51,6 +51,14 @@ Note that when you see `[content]`, this means you can pass in optional content 2. `MetaOg(property, content)` 3. `Icon(path [, rel, size, type])` + +### WIP + +1. `Script` +2. `Img` +3. `Picture` +4. etc. + ## Generate Html Tags _(new in 1.2)_ 1. `Tag(name, [...])` _HtmlString_ - generate an html-tag. Uses `Tags.Open(...)` and `Tags.Close(...)` internally. _v1.2_