Your first example the problem is that repeat is expecting an array
(enumerable actually) or arraylike object.  It then repeats over each
item in the list setting the context as that individual item.
Collection is also expecting an array (etc.) and would by default call
the card for each item in the array.  When you do the two, unless you
have a list of lists it's going to break.

To translate to ruby what's happening as I found that to be a bit
confusing to follow what that means:

@all = Model.all #set in controller, is an array of models

@all.each do |item_from_all|   # this is the repeat in a sense, from
above will repeat over individual models
  item_from_all.each do |item_from_item_from_all|  # this is the
collection call.  note, it's trying to enumerate a single model
    card(item_from_item_from_all) # default for collection, not actual
method
  end
end

really, all you'd need is <collection with="&@all" /> to get a list of
cards for each of the @all models (they don't even have to be the same
model type!).

The implicit context is one of the hardest things to grasp a hold of
in dryml but makes for extremely clean markup and powerful
(polymorphism, view helpers, changeable parameters all rolled into
one).  Check out the dryml guide 
http://cookbook.hobocentral.net/manual/dryml-guide
and then start out with small changes.  You will love it. you never
have to write another nested for loop or partial again.  that alone is
worth it for triple the code readability.

On Jul 27, 12:09 pm, Skott Klebe <[email protected]> wrote:
> I'm frustrated with DRYML and Rapid.
> I can sense the power, but I can't figure out how to get at it.
> Literally everything I try to do breaks, and I can't figure out why.
>
> For instance, I have an array of model instances returned by find.
> I'd like to try something like this:
> <repeat with="&@all">
>       <collection/>
> </repeat>
>
> where @all=<Model>.find :all, populated in the controller. This seems
> like a minimal change from what's in the Agility tutorial, and I can't
> tell what's wrong, but I get a method missing exception on empty?.
> Eventually I gave up on using <collection> entirely.
>
> I want to modify the edit form so that it shows a textarea instead of
> an input type='text' for one field, and there doesn't seem to be any
> end to the work.  I create the edit-page, I drop the field from the
> field_list, and add the field back in; now it doesn't get put into the
> table of label/field combos, and doesn't have a label.
> According to the Rapid doc, it seems like I would get a textarea
> automagically if I declared the field in my model as note instead of
> string, but I shouldn't have to change the data layer to get the
> presentation layer that I want.  I feel like there's should be a
> simpler way to do this, but for the life of me I can't find it in the
> doc.
>
> At this point I feel like I've killed 24hrs of duration and close to
> 10hrs of effort on simple functionality that would have taken one or
> two minutes to do in erb or haml.  Neither erb nor haml offers the
> promise of modularity and nearly semantic markup that DRYML seems to,
> but then, I've never had as much trouble making simple markup changes
> before.
>
> There's deep thinking about the structure of web apps embedded in
> DRYML and Rapid, but I'm running out of time to leverage it.
>
> Should I keep going? Does it take one or two days of absolute
> paralysis before I'll start to be able to jump higher and farther than
> ever before?
>
> SK
>
> --
> Skott Klebe
> [email protected]

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to