Basic/Base App with Go-Macaron. With user registration/login/logout, one simple admin page and user profile edit. Taken from my git.txt to simplify laters dev app.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

query.go 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package goquery
  2. import "golang.org/x/net/html"
  3. // Is checks the current matched set of elements against a selector and
  4. // returns true if at least one of these elements matches.
  5. func (s *Selection) Is(selector string) bool {
  6. return s.IsMatcher(compileMatcher(selector))
  7. }
  8. // IsMatcher checks the current matched set of elements against a matcher and
  9. // returns true if at least one of these elements matches.
  10. func (s *Selection) IsMatcher(m Matcher) bool {
  11. if len(s.Nodes) > 0 {
  12. if len(s.Nodes) == 1 {
  13. return m.Match(s.Nodes[0])
  14. }
  15. return len(m.Filter(s.Nodes)) > 0
  16. }
  17. return false
  18. }
  19. // IsFunction checks the current matched set of elements against a predicate and
  20. // returns true if at least one of these elements matches.
  21. func (s *Selection) IsFunction(f func(int, *Selection) bool) bool {
  22. return s.FilterFunction(f).Length() > 0
  23. }
  24. // IsSelection checks the current matched set of elements against a Selection object
  25. // and returns true if at least one of these elements matches.
  26. func (s *Selection) IsSelection(sel *Selection) bool {
  27. return s.FilterSelection(sel).Length() > 0
  28. }
  29. // IsNodes checks the current matched set of elements against the specified nodes
  30. // and returns true if at least one of these elements matches.
  31. func (s *Selection) IsNodes(nodes ...*html.Node) bool {
  32. return s.FilterNodes(nodes...).Length() > 0
  33. }
  34. // Contains returns true if the specified Node is within,
  35. // at any depth, one of the nodes in the Selection object.
  36. // It is NOT inclusive, to behave like jQuery's implementation, and
  37. // unlike Javascript's .contains, so if the contained
  38. // node is itself in the selection, it returns false.
  39. func (s *Selection) Contains(n *html.Node) bool {
  40. return sliceContains(s.Nodes, n)
  41. }