Created
November 12, 2018 14:34
-
-
Save jjn1056/83fd4e94b0ff84603b20fdcbcf98960c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.