You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where stuff is a partial, and that partial looks like this:
user: {{ user }}
isX: {{ flags.x }}
Now what provides the data to the template is a class that acts as a 'view model' so I can normalise some of the data and have the template interact with the normalised data rather than the raw json data shown above.
The problem is I don't know how to implement my view model to work with the fact we're looping through nested data.
Using the above as an example, my raw data uses an array of strings to represent the flags value, where as I want the template to show true or false depending if the value x appears in the flag array.
So I've managed to resolve this issue myself with a change in code design and nesting 'Presenter' classes (but would be interesting to see how others are doing this)...
where self.post is set on the Presenter and provides the raw data we're looking to consume
The Teaser then works effectively the same as this top level Feed presenter, the difference is it's given a different 'context' object (i.e. self.post value) to use as its data source:
Hi
Here is an example of my data's structure:
Now in my template I try to do this:
Where
stuff
is a partial, and that partial looks like this:Now what provides the data to the template is a class that acts as a 'view model' so I can normalise some of the data and have the template interact with the normalised data rather than the raw json data shown above.
The problem is I don't know how to implement my view model to work with the fact we're looping through nested data.
Using the above as an example, my raw data uses an array of strings to represent the
flags
value, where as I want the template to show true or false depending if the valuex
appears in the flag array.In code I might try to implement this like so:
Now the issue here is that for me to write the
namedtuple
code, I need to know which index of the results to be looping over.Am I just missing something really obvious?
The text was updated successfully, but these errors were encountered: