Skip to content

Instantly share code, notes, and snippets.

@xaicron
Created November 18, 2010 06:26
Show Gist options
  • Save xaicron/704691 to your computer and use it in GitHub Desktop.
Save xaicron/704691 to your computer and use it in GitHub Desktop.
package Hoge;
use strict;
use warnings;
sub new {
bless {}, shift;
}
sub all {
return qw(tokuhirom nekokak chiba gfx);
}
package main;
use Text::Xslate;
my $tx = Text::Xslate->new(
syntax => 'TTerse',
);
my $hoge = Hoge->new;
print $tx->render_string(<< 'TEMPLATE', { hoge => $hoge });
[%- FOR foo IN [ hoge.all() ] %]
[% foo %]
[%- END %]
TEMPLATE
__END__
gfx
package Hoge;
use strict;
use warnings;
sub new {
bless {}, shift;
}
sub all {
return [ qw(tokuhirom nekokak chiba gfx) ];
}
package main;
use Text::Xslate;
my $tx = Text::Xslate->new(
syntax => 'TTerse',
);
my $hoge = Hoge->new;
print $tx->render_string(<< 'TEMPLATE', { hoge => $hoge });
[%- FOR foo IN hoge.all() %]
[% foo %]
[%- END %]
TEMPLATE
__END__
tokuhirom
nekokak
chiba
gfx
package Hoge;
use strict;
use warnings;
sub new {
bless {}, shift;
}
sub all {
my @ret = qw(tokuhirom nekokak chiba gfx);
return @ret;
}
package main;
use Text::Xslate;
my $tx = Text::Xslate->new(
syntax => 'TTerse',
);
my $hoge = Hoge->new;
print $tx->render_string(<< 'TEMPLATE', { hoge => $hoge });
[%- FOR foo IN [ hoge.all() ] %]
[% foo %]
[%- END %]
TEMPLATE
__END__
4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment