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

Xpath support #181

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

Xpath support #181

cvalka2 opened this issue May 9, 2013 · 8 comments
Assignees
Milestone

Comments

@cvalka2
Copy link

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
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
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
Copy link
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.

@ghost ghost assigned neocotic May 10, 2013
@neocotic neocotic mentioned this issue May 10, 2013
@neocotic
Copy link
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.

@neocotic
Copy link
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.

@neocotic
Copy link
Member

@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
Projects
None yet
Development

No branches or pull requests

2 participants