-
Notifications
You must be signed in to change notification settings - Fork 307
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
Rendering complex types #167
Comments
The problem is in context.py line 55, I think.
According to the comment there , "Instances of user-defined classes on the other hand, for example, But this is clearly false:
yields However, sabercups example does work if we replace
with
|
Just to clarify, if you change this line--
to--
Does it still not behave as desired? The issue here is old vs new-style classes. IIRC, I believe the code was written with new-style classes in mind. |
Yes, it works fine if we use
So this issue should be labelled "pystache doesn't traverse old-style classes". Which may be acceptable - I don't fully understand the difference between new and old style classes. |
Here's an SO post on the subject (one of many I'm sure): http://stackoverflow.com/questions/54867/old-style-and-new-style-classes-in-python Old-style classes were the way classes were prior to Python 2.2. I'm not sure it's worth supporting old-style because it's a legacy style. For example, in Python 3 all classes are new-style. |
What about backwards compatibility with Python 2? There's still a lot of that around. In any event, perhaps a comment then in pystache.render() to remind everyone to use classes derived from object. |
The oldest version that Pystache supports is Python 2.4, and new-style classes were around back then. I think a code comment and/or note in a docstring comment would be fine. |
Pystache might be having problems rendering data from a complex type. It seems to be fine with dictionaries, however. That said, it doesn't seem to traverse dictionaries that contain complex objects.
Please refer to this:
http://stackoverflow.com/questions/25827884/mustache-pystache-rendering-complex-objects
This breaks:
It yields:
Expected output is:
If you change the last two lines to this:
It will traverse the first dictionary, but then not traverse the inner objects, so you get this:
The following works, but it's a full dictionary
yeilds:
The text was updated successfully, but these errors were encountered: