Idea Delivered

This is being delivered in XPP 9.4

xyPerl: need a better way to check the current context

In xyPerl you can easily check for the presence or get the value of an attribute from a specific ancestor using the rather elegant syntax provided (@name, ../@name, ../../@name, ancestor::element/@name, etc...)

But checking if you are in a certain context is quite cumbersome. You need to do a get_mlh or get_path and then write your own function to detect if you are currently in a certain context.
This could be done a lot easier if we could use similar syntax like for the attributes inside a new xyPerl function (get_context?)

Things could look like this:
if ($X->get_context('ancestor::chapter') ) {
} else {

Remark: one might argue that the context checking might be done inside the CSS, but sometimes you just want to avoid writing 2 similar xyPerl functions and just to the context checking inside your xyPerl function.

Parents Comment Children
No Data