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

->exists() function which returns boolean if element exists #5

Open
mitar opened this issue Oct 26, 2022 · 3 comments
Open

->exists() function which returns boolean if element exists #5

mitar opened this issue Oct 26, 2022 · 3 comments

Comments

@mitar
Copy link

mitar commented Oct 26, 2022

No description provided.

@mitar
Copy link
Author

mitar commented Oct 27, 2022

I implemented one:

func PagserExists(node *goquery.Selection, args ...string) (out interface{}, err error) {
	return node.Length() > 0, nil
}

p.RegisterFunc("exists", PagserExists)

I think it could be added to core functions.

@foolin
Copy link
Owner

foolin commented Oct 29, 2022

Which usages need to use this method?

@mitar
Copy link
Author

mitar commented Oct 29, 2022

I use it like this:

type data struct {
	DialogExists bool `pagser:"#dialog->exists()"`
}

Ideally it would not be needed and the following would just work:

type data struct {
	DialogExists bool `pagser:"#dialog"`
}

But it fails.

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