Changeset 3531 for trunk/lib/MT/Template/Context.pm
- Timestamp:
- 03/12/09 09:11:52 (9 months ago)
- Files:
-
- 1 modified
-
trunk/lib/MT/Template/Context.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/MT/Template/Context.pm
r3082 r3531 1 # Movable Type (r) Open Source (C) 2001-200 8Six Apart, Ltd.1 # Movable Type (r) Open Source (C) 2001-2009 Six Apart, Ltd. 2 2 # This program is distributed under the terms of the 3 3 # GNU General Public License, version 2. … … 30 30 my $ctx = shift; 31 31 weaken($ctx->{config} = MT->config); 32 $ctx->stash('vars', {}); 32 33 $ctx->init_handlers(); 33 34 $ctx; … … 82 83 } 83 84 if (ref($block->{$orig_tag}) eq 'HASH') { 84 $h->{$tag} = [ $block->{$orig_tag}{handler}, $type, $prev_hdlr ]; 85 if ( $block->{$orig_tag}{handler} ) { 86 $h->{$tag} = [ $block->{$orig_tag}{handler}, $type, $prev_hdlr ]; 87 } 85 88 } else { 86 89 $h->{$tag} = [ $block->{$orig_tag}, $type, $prev_hdlr ]; … … 182 185 my ($h) = $ctx->handler_for($tag) or return $ctx->error("No handler for tag $tag"); 183 186 local $ctx->{__stash}{tag} = $tag; 184 return $h->($ctx, @_); 187 my ($args, $cond) = @_; 188 $args ||= {}; 189 my $out = $h->($ctx, $args, $cond); 190 if (defined $out) { 191 if (my $ph = $ctx->post_process_handler) { 192 $out = $ph->( $ctx, $args, $out ); 193 } 194 } 195 return $out; 185 196 } 186 197 … … 446 457 foreach my $tag (@$tags) { 447 458 my $name = $tag->name; 459 ## FIXME: this implementation can't handle tags which starts 460 ## with hash mark and numbers related. because they could break 461 ## our mid-compiled expression. now just skip them. 462 next if $name =~ /^\s*\#\d+\s*$/; 448 463 my $id = $tag->id; 449 if ($tag_expr =~ s/(?<![#\d])\Q$name\E/#$id/g) { 464 465 ## search for tags from expression and replace them with its IDs. 466 ## allowed only existing tag name and some logical operators 467 ## ( AND, OR, NOT, and round brackets ). 468 if ($tag_expr =~ s/ 469 ( 470 \sAND\s 471 | \sOR\s 472 | \s?NOT\s 473 | \( 474 | \A 475 ) 476 \s*? 477 \Q$name\E 478 \s*? 479 ( 480 \Z 481 | \) 482 | \sAND\s 483 | \sOR\s 484 | \sNOT\s 485 ) 486 /$1#$id$2/igx) # Change all matches to #$id (e.g. #932) 487 { 450 488 $tags_used{$id} = $tag; 451 489 } … … 627 665 $tag_name = 'mt' . $tag_name unless $tag_name =~ m/^MT/i; 628 666 return $ctx->error(MT->translate( 629 "You used an '[_1]' tag outside of the context of a npage; " .630 "perhaps you mistakenly placed it outside of a n'MTPages' container?",667 "You used an '[_1]' tag outside of the context of a page; " . 668 "perhaps you mistakenly placed it outside of a 'MTPages' container?", 631 669 $tag_name 632 670 ));
