Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty tag not found #37

Closed
zarghol opened this issue Dec 15, 2016 · 4 comments
Closed

empty tag not found #37

zarghol opened this issue Dec 15, 2016 · 4 comments

Comments

@zarghol
Copy link

zarghol commented Dec 15, 2016

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 !

@tanner0101
Copy link
Member

Can you provide a link to where it says #empty ?

@zarghol
Copy link
Author

zarghol commented Dec 15, 2016

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 :
capture d ecran 2016-12-15 a 23 48 37

@zarghol
Copy link
Author

zarghol commented Dec 15, 2016

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
    }
}

@zarghol
Copy link
Author

zarghol commented Dec 15, 2016

I found in the doc repo which commit delete this :
vapor/docs@9ad6d8e

@zarghol zarghol closed this as completed Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants