-
Notifications
You must be signed in to change notification settings - Fork 168
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
issue #520: provide option to customize stock extensions #552
Conversation
So I came up with "ExtensionCustomizer" to allow filtering out or change whatever functionality is provided by an extension. It currently only targets the baked in extensions - not sure if it would make much sense on the user provided extensions anyway. On the one hand it looks like it leaves the configuration API completely intact and doesn't degrade things like On the other hand I'm not too happy with the current version as now other implementation details, e.g. how core functionality is split over extension classes (core, i18n, escaper) kind of leaks out as you have to know the extension class to apply the customizer. Of course the whole target class thing can be dropped and there could be just one single customizer that is wrapped around every extension before it is loaded ... while thinking about it - i think this is would would provide the cleanest API and won't break things for users if stuff is re-organized internally at some point.. I'll rework it. Feedback is much appreciated! |
super(core); | ||
} | ||
|
||
@Override | ||
public Map<String, Filter> getFilters() { | ||
Map<String, Filter> filters = new HashMap<>(super.getFilters()); | ||
Map<String, Filter> filters = Optional.ofNullable(super.getFilters()).map(HashMap::new) |
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.
just curious: is there a reason why null is acceptable over an empty map/list if filters and others are not provided?
Can you provide some documentation for this new functionality ? |
@ebussieres Ok, I added further JavaDoc - is that okay so far? |
I mean add some documentation for pebble website. Doc is here : https://github.com/PebbleTemplates/pebble/tree/master/docs/src/orchid/resources |
Oh sure, I'll check this out! |
The following example removes the `ForTokenParser`, i.e. the ability to parse `{% for %}{{ ... }}{% endfor %}` constructs: | ||
|
||
```java | ||
class ExampleOptOuts extends ExntensionCustomizer { |
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.
there's a typo in ExntensionCustomizer
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.
🤦 fixed it :)
This is a draft for #520 to allow for a customization of the default extensions.
PebbleEngine.Builder
into theExtensionRegistryFactory
ExtensionCustomizer
which basically allows to access extensions before loading