Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Jul 28, 2023
1 parent 501e6e1 commit eebb46c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Sources/LeafKit/LeafRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public final class LeafRenderer: Sendable {
/// Initial configuration of LeafRenderer.
public init(
configuration: LeafConfiguration,
tags: [String: LeafTag] = defaultLeafTags,
tags: [String: LeafTag] = defaultTags,
cache: LeafCache = DefaultLeafCache(),
sources: LeafSources,
eventLoop: EventLoop,
Expand Down
2 changes: 1 addition & 1 deletion Sources/LeafKit/LeafSerialize/LeafSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ internal struct LeafSerializer {

init(
ast: [Syntax],
tags: [String: LeafTag] = defaultLeafTags,
tags: [String: LeafTag] = defaultTags,
userInfo: [AnyHashable: Any] = [:],
ignoreUnfoundImports: Bool

Expand Down
2 changes: 1 addition & 1 deletion Sources/LeafKit/LeafSource/NIOLeafFiles.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
@preconcurrency import NIO
import NIO

/// Reference and default implementation of `LeafSource` adhering object that provides a non-blocking
/// file reader for `LeafRenderer`
Expand Down
14 changes: 10 additions & 4 deletions Sources/LeafKit/LeafSyntax/LeafTag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public protocol LeafTag: Sendable {
/// Tags conforming to this protocol do not get their contents HTML-escaped.
public protocol UnsafeUnescapedLeafTag: LeafTag {}

public let defaultLeafTags: [String: LeafTag] = [
let _defaultTags = SendableBox<[String: LeafTag]>([
"unsafeHTML": UnsafeHTML(),
"lowercased": Lowercased(),
"uppercased": Uppercased(),
Expand All @@ -20,10 +20,16 @@ public let defaultLeafTags: [String: LeafTag] = [
"count": Count(),
"comment": Comment(),
"dumpContext": DumpContext()
]
])

@available(*, deprecated, renamed: "defaultRendererTags", message: "This variable is concurrently unsafe and is deprecated")
public var defaultTags: [String: LeafTag] = defaultLeafTags
public var defaultTags: [String: LeafTag] {
get {
_defaultTags.value
}
set(newValue) {
_defaultTags.value = newValue
}
}

struct UnsafeHTML: UnsafeUnescapedLeafTag {
func render(_ ctx: LeafContext) throws -> LeafData {
Expand Down
2 changes: 1 addition & 1 deletion Tests/LeafKitTests/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal class TestRenderer: @unchecked Sendable {
private var counter: Int = 0

init(configuration: LeafConfiguration = .init(rootDirectory: "/"),
tags: [String : LeafTag] = defaultLeafTags,
tags: [String : LeafTag] = defaultTags,
cache: LeafCache = DefaultLeafCache(),
sources: LeafSources = .singleSource(TestFiles()),
eventLoop: EventLoop = EmbeddedEventLoop(),
Expand Down

0 comments on commit eebb46c

Please sign in to comment.