Make MustacheSequence public (#38)
* Make `MustacheSequence` public * `MustacheSequence` require conformance to `Sequence` * remove protocol requirements * `MustacheContext` revert to `internal`
This commit is contained in:
@@ -13,14 +13,9 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// Protocol for objects that can be rendered as a sequence in Mustache
|
/// Protocol for objects that can be rendered as a sequence in Mustache
|
||||||
protocol MustacheSequence {
|
public protocol MustacheSequence: Sequence {}
|
||||||
/// Render section using template
|
|
||||||
func renderSection(with template: MustacheTemplate, context: MustacheContext) -> String
|
|
||||||
/// Render inverted section using template
|
|
||||||
func renderInvertedSection(with template: MustacheTemplate, context: MustacheContext) -> String
|
|
||||||
}
|
|
||||||
|
|
||||||
extension Sequence {
|
extension MustacheSequence {
|
||||||
/// Render section using template
|
/// Render section using template
|
||||||
func renderSection(with template: MustacheTemplate, context: MustacheContext) -> String {
|
func renderSection(with template: MustacheTemplate, context: MustacheContext) -> String {
|
||||||
var string = ""
|
var string = ""
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ extension MustacheTemplate {
|
|||||||
/// - Returns: Rendered text
|
/// - Returns: Rendered text
|
||||||
func renderSection(_ child: Any?, with template: MustacheTemplate, context: MustacheContext) -> String {
|
func renderSection(_ child: Any?, with template: MustacheTemplate, context: MustacheContext) -> String {
|
||||||
switch child {
|
switch child {
|
||||||
case let array as MustacheSequence:
|
case let array as any MustacheSequence:
|
||||||
return array.renderSection(with: template, context: context)
|
return array.renderSection(with: template, context: context)
|
||||||
case let bool as Bool:
|
case let bool as Bool:
|
||||||
return bool ? template.render(context: context) : ""
|
return bool ? template.render(context: context) : ""
|
||||||
@@ -124,7 +124,7 @@ extension MustacheTemplate {
|
|||||||
/// - Returns: Rendered text
|
/// - Returns: Rendered text
|
||||||
func renderInvertedSection(_ child: Any?, with template: MustacheTemplate, context: MustacheContext) -> String {
|
func renderInvertedSection(_ child: Any?, with template: MustacheTemplate, context: MustacheContext) -> String {
|
||||||
switch child {
|
switch child {
|
||||||
case let array as MustacheSequence:
|
case let array as any MustacheSequence:
|
||||||
return array.renderInvertedSection(with: template, context: context)
|
return array.renderInvertedSection(with: template, context: context)
|
||||||
case let bool as Bool:
|
case let bool as Bool:
|
||||||
return bool ? "" : template.render(context: context)
|
return bool ? "" : template.render(context: context)
|
||||||
|
|||||||
Reference in New Issue
Block a user