Closed emteknetnz closed 4 months ago
I had to dive in and try to get this working myself to wrap my head around it. I ended up with these commits which handle allowing primitives to be used in templates, and allowing iterators such as ArrayIterator
to work natively in templates.
I cam to the same conclusion as you regarding arrays though - even though SSViewer_Scope::next()
has a comment saying the item could be an array, and handles that, there's no way to actually have an array there unless we update ViewableData::obj()
to return them.
I think we need to do two things:
ViewableData::obj()
to return arrays directly if there are anyViewableData::obj()
to wrap arrays in either a list or ArrayData
depending on what type of array they areArrayList
to either never wrap arrays, or to always wrap them in either a list or ArrayData
depending on what type of array they areViewableData
- though that may be more effort than it's worthI'd say update this PR to handle point 1 above, and raise a new card to look at point 2 since that'll need to go through refinement.
Considering there's a ton of ways point 2 could go, that may even be worth discussing in an architecture catchup.
I'll close the PR to retain the diff for the CMS 6 card and open a new one to do just the scalars
Issue https://github.com/silverstripe/silverstripe-framework/issues/11196