From 8282b10d72ae6e4e5f7a19a69c64bb2370146a2a Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Sun, 29 Aug 2021 16:52:52 +0200 Subject: [PATCH 1/2] Add the Main tag to the TemplateBuilder --- .../View Builders/TemplateBuilder.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sources/HTMLKit/View Builders/TemplateBuilder.swift b/Sources/HTMLKit/View Builders/TemplateBuilder.swift index 0d42f393..11aa5854 100644 --- a/Sources/HTMLKit/View Builders/TemplateBuilder.swift +++ b/Sources/HTMLKit/View Builders/TemplateBuilder.swift @@ -2071,3 +2071,22 @@ public struct Viewport: HTMLComponent { Meta().name(.viewport).content("width=\(mode.width), initial-scale=\(internalScale)") } } + +/// The
tag defines the dominant content of a document. +public struct Main: ContentNode { + + public var name: String { "main" } + + public var attributes: [HTMLAttribute] = [] + + public var content: HTML + + public init(@HTMLBuilder builder: () -> HTML) { + content = builder() + } + + public init(attributes: [HTMLAttribute] = [], content: HTML = "") { + self.content = content + self.attributes = attributes + } +} From b3282b3e70482f3e1dff8f4acf356bba6d7241c7 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Sun, 29 Aug 2021 17:00:32 +0200 Subject: [PATCH 2/2] Correct spelling of environment in the Localize file --- Sources/HTMLKit/Localize.swift | 10 +++++----- Tests/HTMLKitTests/HTMLTestDocuments.swift | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/HTMLKit/Localize.swift b/Sources/HTMLKit/Localize.swift index 6d0fb425..6e78912b 100644 --- a/Sources/HTMLKit/Localize.swift +++ b/Sources/HTMLKit/Localize.swift @@ -60,7 +60,7 @@ extension Localized where B == NoData { } } -public struct EnviromentModifier: HTML { +public struct EnvironmentModifier: HTML { let view: HTML let locale: HTML @@ -82,11 +82,11 @@ public struct EnviromentModifier: HTML { } extension HTML { - public func enviroment(locale: String) -> EnviromentModifier { - return EnviromentModifier(view: self, locale: locale) + public func environment(locale: String) -> EnvironmentModifier { + return EnvironmentModifier(view: self, locale: locale) } - public func enviroment(locale: TemplateValue) -> EnviromentModifier { - return EnviromentModifier(view: self, locale: locale) + public func environment(locale: TemplateValue) -> EnvironmentModifier { + return EnvironmentModifier(view: self, locale: locale) } } diff --git a/Tests/HTMLKitTests/HTMLTestDocuments.swift b/Tests/HTMLKitTests/HTMLTestDocuments.swift index c70a5ee8..c6d089dc 100644 --- a/Tests/HTMLKitTests/HTMLTestDocuments.swift +++ b/Tests/HTMLKitTests/HTMLTestDocuments.swift @@ -740,7 +740,7 @@ struct LocalizedView: HTMLTemplate { P("unread.messages", with: ["numberTest": 2]) P("unread.messages", with: context) } - .enviroment(locale: context.locale) + .environment(locale: context.locale) } } @@ -859,7 +859,7 @@ struct LocalizedDateView: HTMLTemplate { context.date.formatted(string: "MM/dd/yyyy") } } - .enviroment(locale: context.locale) + .environment(locale: context.locale) } }