Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Created November 12, 2018 14:34
Show Gist options
  • Save jjn1056/83fd4e94b0ff84603b20fdcbcf98960c to your computer and use it in GitHub Desktop.
Save jjn1056/83fd4e94b0ff84603b20fdcbcf98960c to your computer and use it in GitHub Desktop.
<List items=self.names />
<PersonItem name=parent.name
age=parent.age />
</List>
<List items=self.names />
<PersonItem @id=myItems
name=parent.name
age=parent.age />
</List>
Package List;
has content => (is=>'ro', required=>1);
has items => (is=>'ro', required=>1, isa=>ArrayRef);
sub process {
$self->for('#content_area') => sub {
$self->content->repeat($self->items);
};
}
sub template {
return q[
<ul>
<li id='content_area'/>
</ul>
}
package PersonItem;
extends 'ListItem';
@jjn1056
Copy link
Author

jjn1056 commented Nov 12, 2018

Basically any component that wants to have its content repeat needs to inherit from List component and that will automatically do the repeat for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment