See my answer here:
fooobar.com/questions/362242 / ...
But, in short, you can access context from a custom filter by retrieving it from the call stack when and only when the filter is called during rendering.
This is admittedly a haphazard solution. Let the buyer be vigilant.
source share