I am trying to learn more about groovy. Specifically my use case is to read an html document and parse out info and maybe add some data to the html. I found this post on a similar subject: groovy parse local html file but I don't understand some of the syntax and functions used.
For example, in this response I don't really understand what the ".with" does and the ".'**'".
So I'm hoping someone can point me to some documentation or additional info on these kind of expressions and functions. I generally understand this use case but I want to have a better understanding so I can adapt it to my needs.
Thanks for any help or guidance.
with is described here in the documentation https://groovy-lang.org/style-guide.html#_using_code_with_code_and_code_tap_code_for_repeated_operations_on_the_same_bean
And ** is described here in the documentation (it means depth first traversal): https://groovy-lang.org/processing-xml.html#_flexible_navigation_with_children_depthfirst_and_breadthfirst
Related
I am working in a project where i need to understand gherkin parsing better than ever. Also need to implement certain higher order functionalities based on content.
I wanted to know how to convert cucumber gherkin feature files into JSON or to get it into AST Tree. I tried using Gherkin package from npm repo but i am not able to get the stream out into json with all the content. Can someone help me with an example or sample code to extract a feature step to AST or JSON format. Please help..
Thanks in advance.
According to the Gherkin documentation, you can use the Gherkin CLI to produce an AST as a JSON object. There are plenty of examples of the output and command-line parameters on their GitHub repository. Since you are parsing Gherkin, which is programming language-agnostic, you can use whichever implementation of Gherkin you prefer.
In Twig internal documentation we can read that lexer could be changed:
$twig->setLexer($lexer);
My question is: Is possible to extend from Twig_Lexer?
When reading the code I can see most members are private, this makes harder the reuse of members or extending at all. Also the setLexer() from Twig_Environment has a type hint for Twig_Lexer.
What am I missing here ?
Thanks in advance.
As documentation purpose. The answer to this question can be seen in this issue
Basically all extension from internal classes is discouraged and will not be supported in Twig.
As I have asked questions in this form - thanks for your many helpful answers - i have found many really neat things that one can do using ExtLibUtil.???? however, other than a bit here and a bit there I have not found anything that gives a listing on the various functions. I one post I read that it is all in the source of the extension Library, and it might be if you really understand where in the source to look. Sure would appreciate a pointer and starting point.
I've been unable to find a JavaDoc for it. The library slipped passed us when we wrote the book - certainly I was not as au fait with Java to be aware of it and all the strength within it. So the best option currently is to look at the source code in Eclipse. Many of the methods are helper methods to easily access things like viewScope etc, which is easy from SSJS but less easy from Java. Most are pretty self-explanatory.
Content assist doesn't seem to work from SSJS, but will from any Java class or, alternatively, open up one of the Java classes created for XPages / Custom Controls under the "local" package in Package Explorer, type "ExtLibUtil." in any method and you'll see the list.
I want to write a new input method for iBus. Specifically for ibus-m17n.
Can somebody point me to some web pages that help to understand the format of mim files used for ibus-m17n?
Well there is the doc and look at layout already created MIMs. They also have a mailing list.
Its some form of lisp, I havent done anything more than simple keymappings myself.
What is the use of .# in groovy? Can anyone explain me with a code snippet?
Have you seen the official documentation? It contains nice code samples.
Essentially, when you use normal . operator, you access fields indirectly, using implicitly generated getters/setters. However, .# allows you to access the field directly, skipping getter/setter.
This can be useful when you want to avoid some additional logic implemented in getter/setter and change the field directly. Violates tons of OOP principles, but the authors of Groovy found this construct to be useful.
That's the Java Field operator (according to the documentation)
There are examples in the documentation.
It is also used for accessing attributes when you are parsing XML (again, there's an example if you follow that link).