[system] / trunk / webwork-modperl / lib / WeBWorK / ContentGenerator.pm Repository:
ViewVC logotype

Diff of /trunk/webwork-modperl/lib/WeBWorK/ContentGenerator.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 526 Revision 555
16use Apache::Constants qw(:common); 16use Apache::Constants qw(:common);
17use CGI qw(); 17use CGI qw();
18use URI::Escape; 18use URI::Escape;
19use WeBWorK::DB::Auth; 19use WeBWorK::DB::Auth;
20use WeBWorK::Utils qw(readFile); 20use WeBWorK::Utils qw(readFile);
21#use CGI::Carp qw(fatalsToBrowser); 21use Carp qw(cluck);
22 22
23################################################################################ 23################################################################################
24# This is a very unruly file, so I'm going to use very large comments to divide 24# This is a very unruly file, so I'm going to use very large comments to divide
25# it into logical sections. 25# it into logical sections.
26################################################################################ 26################################################################################
103 # 103 #
104 # Let's try something else instead: 104 # Let's try something else instead:
105 my @template = split /\n/, readFile($templateFile); 105 my @template = split /\n/, readFile($templateFile);
106 106
107 foreach my $line (@template) { 107 foreach my $line (@template) {
108 #warn "foo: $line\n";
109 # This is incremental regex processing. 108 # This is incremental regex processing.
110 # the /c is so that pos($line) doesn't die when the regex fails. 109 # the /c is so that pos($line) doesn't die when the regex fails.
111 while ($line =~ m/\G(.*?)<!--#(\w*)((?:\s+.*?)?)-->/gc) { 110 while ($line =~ m/\G(.*?)<!--#(\w*)((?:\s+.*?)?)-->/gc) {
112 my ($before, $function, $raw_args) = ($1, $2, $3); 111 my ($before, $function, $raw_args) = ($1, $2, $3);
113 # $args here will be a hashref
114 my @args = $raw_args =~ /\S/ ? cook_args($raw_args) : {}; 112 my @args = ($raw_args =~ /\S/) ? cook_args($raw_args) : ();
113
115 if ($ifstack[-1]) { 114 if ($ifstack[-1]) {
116 print $before; 115 print $before;
117 } 116 }
118 117
119 if ($self->can($function)) { 118 if ($self->can($function)) {
120 if ($function eq "if") { 119 if ($function eq "if") {
121 push @ifstack, $self->$function(@_, [@args]); 120 push @ifstack, $self->$function(@_, [@args]);
122 } elsif ($function eq "else" and @ifstack > 1) { 121 } elsif ($function eq "else" and @ifstack > 1) {
123 $ifstack[-1] = not $ifstack[-1]; 122 $ifstack[-1] = not $ifstack[-1];
306# Generic versions of template escapes 305# Generic versions of template escapes
307################################################################################ 306################################################################################
308 307
309# Reminder: here are the template functions currently defined: 308# Reminder: here are the template functions currently defined:
310# 309#
310# head
311# path 311# path
312# style = text|image 312# style = text|image
313# image = URL of image 313# image = URL of image
314# text = text separator 314# text = text separator
315# links 315# links

Legend:
Removed from v.526  
changed lines
  Added in v.555

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9