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') ) {
   doSomething();
} else {
   doSomethingElse();
}

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
  • Sounds like a good idea Bart.

    A XyPerl function that tests the current hierarchical position against a test value, which the user could present in a similar format as already implemented for the get_attr function, would be a welcome addition to the good array of functions already available to the XPP styler and help to streamline their XyPerl code.
     

Comment
  • Sounds like a good idea Bart.

    A XyPerl function that tests the current hierarchical position against a test value, which the user could present in a similar format as already implemented for the get_attr function, would be a welcome addition to the good array of functions already available to the XPP styler and help to streamline their XyPerl code.
     

Children
No Data