empty tag not found
zarghol opened this issue · comments
When I want to use the #empty(variable)
syntax, I got this error :
ParseError.tagTemplateNotFound("empty")
In the documentation, the empty tag is used to test is a variable is empty, but it doesn't work. When I go into the Constants.swift of Leaf, there is no empty...
thanks for help !
Can you provide a link to where it says #empty
?
It was at this url : https://vapor.github.io/documentation/guide/leaf.html at the Chaining paragraph.
When I refreshed the page, the page changed and no longer showed #empty
...
Fortunately, I took a screenshot before to refresh :
to use it in my project, I wrote it as a custom tag :
import Foundation
import Vapor
import Leaf
class Empty: BasicTag {
let name = "empty"
func run(arguments: [Argument]) throws -> Node? {
guard arguments.count > 0 else {
return Node("empty")
}
for arg in arguments {
guard let val = arg.value, !val.isNull else {
return Node("empty")
}
if let arr = val.array, arr.count == 0 {
return Node("empty")
}
if let dico = val.nodeObject, dico.count == 0 {
return Node("empty")
}
}
return nil
}
}
I found in the doc repo which commit delete this :
vapor/docs@9ad6d8e