pagser icon indicating copy to clipboard operation
pagser copied to clipboard

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

Open mitar opened this issue 3 years ago • 3 comments

mitar avatar Oct 26 '22 18:10 mitar

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.

mitar avatar Oct 27 '22 08:10 mitar

Which usages need to use this method?

foolin avatar Oct 29 '22 02:10 foolin

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.

mitar avatar Oct 29 '22 06:10 mitar