-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic Processors #1045
Generic Processors #1045
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of making this usable across more operations in Jinjava. Are there any filters, in particular, you're interested in timing?
JinjavaProcessors processors = interpreter.getConfig().getProcessors(); | ||
|
||
try { | ||
if (processors != null && processors.getFilterPreProcessor() != null) { | ||
processors.getFilterPreProcessor().accept(this, interpreter); | ||
} | ||
return filter(var, interpreter, filterArgs); | ||
} finally { | ||
if (processors != null && processors.getFilterPostProcessor() != null) { | ||
processors.getFilterPostProcessor().accept(this, interpreter); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many filters override this. Also, this doesn't time filtering when the var is a SafeString
If you really want to time all filters, you'd probably need to proxy the classes in filters, exptests, and functions in FilterLibrary, ExpTestLibrary, and FunctionLibrary when calling addFilter
, addExpTest
, and addFunction
, respectively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I know it won't catch everything, but it does catch most. I added a comment to explain that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could instead add processors within JinjavaInterpreterResolver.invoke
or some other place within the ELResolver code to get around this.
I'm not really concerned with filters right now, but it was an easy demonstration for how to use processors for functionality besides nodes. Nodes probably covers it for what I'm concerned with since all filters and functions will be part of a node. |
I've removed the filter processors for now since I don't need them. |
I decided to just implement a more generic version of #1044 so we could easily add processors for pre and post execution of nodes and now filters. In the future we could add tags and functions to the builder.