tomj74 / chunk-templates

Chunk Templates, a template engine for Java
http://www.x5software.com/chunk/
MIT License
77 stars 10 forks source link

Chunk seems to ignore classes that contain certain things like enums. #18

Closed legendarylarry closed 8 years ago

legendarylarry commented 8 years ago

I am using like 20 model classes passing them to Chunk templates just fine. But 2 of my classes, Chunk just treats them as if they are undefined, {$job.name} just shows up in the final html as {$job.name}, even when I know it's defined from debugger, etc. The only thing different about these 2 that I can see is they define some enums inside the class.

So I created a very simple class ChunkyTest that just had 1 field ( name ) and a setter and getter. I pass it to chunk and it works {$chunky.name} shows the correct value. Then I add this inside ChunkyTest:

public enum Type { SHOWER }
public static transient Type SHOWER = Type.SHOWER;  

And now {$chunky.name} shows up in html as {$chunky.name} and never gets processed.

I don't know specifically which thing breaks it, but this is narrow enough to report, and took a long time to find!

Thank you for chunk-templates.

tomj74 commented 8 years ago

Thanks for the reproduce case. Will tackle this asap.

tomj74 commented 8 years ago

Actually I'm having trouble reproducing this issue. There was a fix for a similar issue in 3.1.2, do you know what version of chunk that you are on?

legendarylarry commented 8 years ago

I was using 3.0.2 but during the investigation yesterday I updated my pom.xml to use 3.2.0. I'll double check that my deployment is using the newer version.

legendarylarry commented 8 years ago

Yeah it looks like I'm using 3.2.0. For now I'm okay after moving these enums outside the classes to their own files everything is working for me. I'm pretty sure that my ChunkyTest example was after the 3.2.0 upgrade, as I tried the upgrade first when I was having the issue, but I could be mistaken.

Is there a way to turn on some logging or exception-throwing for chunk templates so I can get you some more data?

tomj74 commented 8 years ago

I mocked this up to your description but can't reproduce the failure in 3.2.0. Closing this issue.

Oh by the way, I was not familiar with the transient field mod until now -- given the description (to mark a field that should not be serialized), would you expect this field to be available to the template or not? Just curious. Current chunk behavior is to make the field visible to the template.

legendarylarry commented 8 years ago

Good question. My initial thought is that transient fields should not be available to the template. This could be a way to purposefully mark sensitive fields as unavailable to the template, similarly to how they would be excluded in some e.g. json serialization of the object.