racke / Template-Flute

Template::Flute - Modern designer-friendly HTML templating Engine
Other
11 stars 12 forks source link

Are containers possible nested within lists? #61

Closed murwiz closed 9 years ago

murwiz commented 10 years ago

I'm attempting to create a "report-break" product listing, e.g.,

Product Group Name -- Category Name Product #1 Product #2 Product #3 -- Another Category Name Product #4 Product #5

Another Product Group Name etc. (The line breaks in the above are strictly for clarity.)

My approach was to define a <list> to show one product, with an optional "break" displayed based on the context of the current iterator item. So my specification looks like this:

`

...
<container name="group_break" field="product_group_break">
  <value name="product_group_name" field="product_group_break.name"/>
  <value name="category_name" field="category_break.name"/>
</container>
<container name="cat_break" field="category_break">
  <value name="category_name" field="category_break.name"/>
</container>

`

My question is, can a <container> exist within a <list>, and if so, what are the rules for referencing the iterator item? Should these <container> tags have <param> within them?

murwiz commented 10 years ago

I was inspired to look in the *.t files for some of this functionality, and I realized my error: <container> is more of a declarative thing than a nestable structure. Ignore this for now; I'll revisit it if my new knowledge doesn't get me un-stuck.

racke commented 10 years ago

I suppose you could use nested lists for this purpose.

murwiz commented 10 years ago

Nope, that* didn't solve my problem. I need to look at some more complex examples of specifications and templates; if you can point me to some, that might be all I need. If not, I'll have to send you what I have in hopes you can see where I'm going wrong.

*By which I mean, what I was alluding to, not your nested-list suggestion. I am not sure how a nested list would help.

murwiz commented 10 years ago

This is still an issue for me. Specifically this rather common case:

I am displaying a list of products with a <list iterator="products">. Within that, I need to display one of two chunks of HTML based on whether the product can be ordered from within that list page, or if you must click to the flypage to order it. (Because the product has complex options, or variants, which discourages a simple add-to-cart button among the list of products.)

I can boil down the decision to a method on a $product, and thus define this container:

<container name="can_purchase" value="is_canonical&!has_variants"/> <container name="cannot_purchase" value="!is_canonical&|has_variants"/>

However, at the level of the list item, the container does not seem to be using the current product in each row.

murwiz commented 10 years ago

Corrected markup for readability.

racke commented 9 years ago

Please test this again with the upcoming 0.0150 release.

racke commented 9 years ago

No feedback, thus closing the issue.