Changeset 969
- Timestamp:
- 08/20/08 03:24:22 (3 months ago)
- Files:
-
- trunk/examples/Example2 (copied) (copied from trunk/examples/Example1)
- trunk/examples/Example2/plugins/Example/config.yaml (modified) (1 diff)
- trunk/examples/Example2/plugins/Example/lib/Example/Plugin.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/examples/Example2/plugins/Example/config.yaml
r967 r969 6 6 version: 1.0 7 7 tags: 8 function: 9 'SaySomething': $Example::Example::Plugin::SaySomething 10 'SayWhatever': $Example::Example::Plugin::SayWhatever 11 block: 12 'LoopTenTimes': $Example::Example::Plugin::LoopTenTimes 13 'IfOdd?': $Example::Example::Plugin::IfOdd 8 tags: 9 modifier: 10 'lolcats': $Example::Example::Plugin::lolcats 14 11 trunk/examples/Example2/plugins/Example/lib/Example/Plugin.pm
r967 r969 9 9 10 10 ############################################################# 11 =head2 SaySomething11 =head2 lolcats 12 12 13 This tag outputs the word "Something." 13 A template tag modifer that appends "LOL - CAN I HAZ" to the 14 contents of the associated tag. 14 15 15 16 =cut 16 sub SaySomething { 17 my ($ctx, $args) = @_; 18 return "Something""; 19 } 20 21 ############################################################# 22 =head2 SayWhatever 23 24 This tag takes as input a string that is then echo'ed back. 25 26 =over 4 27 28 =item * say 29 30 Whatever you want to tag to echo. 31 32 =back 33 34 B<Example:> 35 36 <mt:SayWhatever say="Hello World!"> 37 38 =cut 39 sub SayWhatever { 40 my ($ctx, $args) = @_; 41 # What the person passed in through the argument 'say' 42 my $input = $args->{'say'}; 43 return $input; 44 } 45 46 sub LoopTenTimes { 47 my ($ctx, $args, $cond) = @_; 48 my $out = ""; 49 my $builder = $ctx->stash('builder'); 50 my $tokens = $ctx->stash('tokens'); 51 for (my $i = 1; $i <= 10; $i++) { 52 $ctx->stash("current_loop_number",$i); 53 $out .= "$i - " . $builder->build($ctx,$tokens,$cond); 54 } 55 return $out; 56 } 57 58 sub IfOdd { 59 my ($ctx, $args, $cond) = @_; 60 my $num = $ctx->stash('current_loop_number'); 61 if ($num % 2 == 0) { 62 return 0; 63 } else { 64 return 1; 65 } 17 sub lolcats { 18 my ($str, $val, $ctx) = @_; 19 return "LOL - CAN I HAZ $str"; 66 20 } 67 21
