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.
Related
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
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.
Can somebody give me a use case as to how can the PortletURLListener be used? if it can be used at all?
Like we have ModelListener can we also use PortletURLListener?
Just like in ModelListener we can inject functionality on creation of a model, on update of a model or on delete and so on.
So can we use the PortletURLListener the same way like ModelListener to do
something when a specific URL is called? Any other approach if not PortletURLListener? Since the name is such I thought that could be of help.
And can we use it in a hook? or it is just used by Liferay? Any other practical usecase you have seen or implemented by extending or using this class?
Thanks in advance.
Thanks Mark for the prompt :-)
The PortletURLListener is used e.g. for deploying and undeploying by Liferay core. For more details see Liferay sources for PortletHotDeployListener:
https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/deploy/hot/PortletHotDeployListener.java
Answer after Update:
You can create hook and put servlet.service.events.post=com.my.MyAfterChangeAction propery to the portal.properties. The MyAfterChangeAction class must implements com.liferay.portal.kernel.events.Action.
Can anyone tell me where com.ibm.xsp.component.UIIncludeComposite is documented? I searched in the help file for UIIncludeComposite but found nothing.
There is only one brief mention of it in Mastering xPages.
com.ibm.xsp.component.UIIncludeComposite is the class for the object returned by getComponent when calling getComponent for a custom control.
In fact where is anything documented? I think the single biggest frustration as a newbie xPage programmer is the lack of documentation or where to find it.
The Java class is documented in the Javadoc available at http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Domino_Designer_Extensibility_APIs_Javadoc_8.5.3 which points to this page for the specific class:
http://public.dhe.ibm.com/software/dw/lotus/Domino-Designer/JavaDocs/DesignerAPIs/com/ibm/xsp/component/UIIncludeComposite.html
General documentation for Upgrade Pack 1 and Extension Library is available here:
http://www-10.lotus.com/ldd/ddwiki.nsf/xpViewCategories.xsp?lookupName=Domino%20Designer%20XPages%20Extension%20Library
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).