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

Xpath support #181

Closed
cvalka2 opened this Issue May 9, 2013 · 8 comments

Comments

Projects
None yet
2 participants
@cvalka2

cvalka2 commented May 9, 2013

Xpath for the select operator and others.

Why not crowdfund this feature on https://www.catincan.com ? I'd personally make a pledge.

Public disclosure: I'm affiliated with Catincan.

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 9, 2013

Member

Are you suggesting the same operations as query selectors? For example:

  • select -> xpath
  • selectAll -> xpathAll
  • selectAllHTML -> xpathAllHTML
  • selectAllMarkdown -> xpathAllMarkdown
  • selectHTML -> xpathHTML
  • selectMarkdown -> xpathMarkdown

This will require either some big custom coding or, more likely, use of a JavaScript port of XPath support. Should definitely be doable and I can imagine it not being too difficult.

Regarding funding; since the donate button on the options page hasn't had a single click I'm not sure Templates users are the funding type. This is not a complaint. I offer Template freely and actually enjoy working on it. I added the donation button out of interest and hope :)

Member

neocotic commented May 9, 2013

Are you suggesting the same operations as query selectors? For example:

  • select -> xpath
  • selectAll -> xpathAll
  • selectAllHTML -> xpathAllHTML
  • selectAllMarkdown -> xpathAllMarkdown
  • selectHTML -> xpathHTML
  • selectMarkdown -> xpathMarkdown

This will require either some big custom coding or, more likely, use of a JavaScript port of XPath support. Should definitely be doable and I can imagine it not being too difficult.

Regarding funding; since the donate button on the options page hasn't had a single click I'm not sure Templates users are the funding type. This is not a complaint. I offer Template freely and actually enjoy working on it. I added the donation button out of interest and hope :)

@cvalka2

This comment has been minimized.

Show comment
Hide comment
@cvalka2

cvalka2 May 9, 2013

Are you suggesting the same operations as query selectors?
Is it possible for an operator (f.e. select) to decide whether it's a CSS selector, Xpath or something else based on the input?
use of a JavaScript port of XPath support
https://github.com/ilinsky/xpath.js ?
I'm not sure Templates users are the funding type.
If you give them some new useful features in return for their donations, they might behave differently.

Offtopic: I'm probably being silly, but how do I split a string into several components in a template? f.e. "My string" -> ["My", "String"]

P.S. Great extension.

cvalka2 commented May 9, 2013

Are you suggesting the same operations as query selectors?
Is it possible for an operator (f.e. select) to decide whether it's a CSS selector, Xpath or something else based on the input?
use of a JavaScript port of XPath support
https://github.com/ilinsky/xpath.js ?
I'm not sure Templates users are the funding type.
If you give them some new useful features in return for their donations, they might behave differently.

Offtopic: I'm probably being silly, but how do I split a string into several components in a template? f.e. "My string" -> ["My", "String"]

P.S. Great extension.

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 9, 2013

Member

Is it possible for an operator (f.e. select) to decide whether it's a CSS selector, Xpath or something else based on the input?

No, document.querySelector can only accept CSS selectors and XPath support isn't built in to the DOM as far as I'm aware.

https://github.com/ilinsky/xpath.js ?

Thanks for the suggestion, I'll have a look into that and other possibilities, should I find any.

If you give them some new useful features in return for their donations, they might behave differently.

But then I can be waiting ages for funding when I'd have already coded the feature and would be dying to release it to my users. I'm too eager 😉

P.S. Thanks! 😄

Member

neocotic commented May 9, 2013

Is it possible for an operator (f.e. select) to decide whether it's a CSS selector, Xpath or something else based on the input?

No, document.querySelector can only accept CSS selectors and XPath support isn't built in to the DOM as far as I'm aware.

https://github.com/ilinsky/xpath.js ?

Thanks for the suggestion, I'll have a look into that and other possibilities, should I find any.

If you give them some new useful features in return for their donations, they might behave differently.

But then I can be waiting ages for funding when I'd have already coded the feature and would be dying to release it to my users. I'm too eager 😉

P.S. Thanks! 😄

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 9, 2013

Member

Sorry, I missed a bit;

Offtopic: I'm probably being silly, but how do I split a string into several components in a template? f.e. "My string" -> ["My", "String"]

This isn't really something I've thought about. Could you please raise another issue for this feature while also specifying why this would be useful and preferably one or more examples.

Member

neocotic commented May 9, 2013

Sorry, I missed a bit;

Offtopic: I'm probably being silly, but how do I split a string into several components in a template? f.e. "My string" -> ["My", "String"]

This isn't really something I've thought about. Could you please raise another issue for this feature while also specifying why this would be useful and preferably one or more examples.

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 10, 2013

Member

It looks like this may be easier than I thought: https://developer.mozilla.org/en/docs/Introduction_to_using_XPath_in_JavaScript

I just have to check browser compatibility and familiarize myself with the implementation.

Member

neocotic commented May 10, 2013

It looks like this may be easier than I thought: https://developer.mozilla.org/en/docs/Introduction_to_using_XPath_in_JavaScript

I just have to check browser compatibility and familiarize myself with the implementation.

@ghost ghost assigned neocotic May 10, 2013

@neocotic neocotic referenced this issue May 10, 2013

Merged

XPath #182

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 10, 2013

Member

I've created pull request #182 to implement this functionality.

@cvalka2 I'd be interested in hearing your opinion on the footnote of that pull request.

Member

neocotic commented May 10, 2013

I've created pull request #182 to implement this functionality.

@cvalka2 I'd be interested in hearing your opinion on the footnote of that pull request.

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 13, 2013

Member

6 new operations have been added to support XPath expressions in your templates. These were added in PR #182 and will be available once v1.2.5 has been released.

Member

neocotic commented May 13, 2013

6 new operations have been added to support XPath expressions in your templates. These were added in PR #182 and will be available once v1.2.5 has been released.

@neocotic neocotic closed this May 13, 2013

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 15, 2013

Member

@cvalka2 Have you had a chance to try these new operations out yet? If so, are you happy with them?

Member

neocotic commented May 15, 2013

@cvalka2 Have you had a chance to try these new operations out yet? If so, are you happy with them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment