Informative toString() for DefaultRockerModel.
The current implementation of DefaultRockerModel#toString() throws an exception. This is generally suboptimal practice as toString() can be called in surprising circumstances.
I propose to submit a patch that does the following:
- Adds
Map<String, ?> getArguments()toRockerModel - Update
JavaGeneratorto implement this method, that constructs such a map on each invocation (i.e. no caching) - Change
DefaultRockerModel#toString()to emit something like:
TemplateClassSimpleName[arg1=value1,arg2=value2]
This would be much more useful in exception messages and debugger UIs.
Sounds like a reasonable enhancement. Couldn't JavaGenerator build a nice toString() method w/o requiring a Map though?
It certainly could. The getArguments() method seems like a reasonable thing to add though for other tooling.
I originally did think about exposing the arguments via a getter method, but Java's standard reflection utilities accomplish the same result. https://github.com/fizzed/rocker/blob/master/runtime/src/main/java/com/fizzed/rocker/BindableRockerModel.java needs to access a model's arguments and it is implemented using standard reflection. I never measured performance I suppose, but even if you get the arguments, you'd still need to use reflection to set/get the values.