40 |
|
|
41 |
sub new { |
sub new { |
42 |
my ($pkg, $filename, $template_name, $validation_name, $template_filename, $safe_write) = @_; |
my ($pkg, $filename, $template_name, $validation_name, $template_filename, $safe_write) = @_; |
43 |
-e $filename or die ("$filename not found"); |
# -e $filename or die ("$filename not found"); |
44 |
|
-e $filename or system("touch", $filename); |
45 |
if ($template_filename) { |
if ($template_filename) { |
46 |
require $template_filename; |
require $template_filename; |
47 |
} else { |
} else { |
320 |
my ($text, $indentation, $comments) = @_; |
my ($text, $indentation, $comments) = @_; |
321 |
my $ret = ''; |
my $ret = ''; |
322 |
my $flag = 1; |
my $flag = 1; |
323 |
|
my $same_line = 0; |
324 |
$indentation = $INDENT_SPACES x $indentation; |
$indentation = $INDENT_SPACES x $indentation; |
325 |
foreach my $comment (@$comments) { |
if (defined $comments) { |
326 |
$comment->{inline} == -1 and $ret .= $indentation . $comment->{comment} . " $text\n", $flag = 0; |
for (my $i;$i<@$comments;$i++) { |
327 |
$comment->{inline} == 0 and $ret .= $indentation . $comment->{comment} . "\n"; |
my $comment = $comments->[$i]; |
328 |
$comment->{inline} == 1 and $ret .= $indentation . "$text " . $comment->{comment} . "\n", $flag = 0; |
if ($comment->{inline} == -1) { |
329 |
|
$ret .= $indentation . $comment->{comment}; |
330 |
|
$same_line = 1; |
331 |
|
if ($i == @$comments-1) { |
332 |
|
$ret .= " $text" . "\n"; |
333 |
|
$flag = 0; |
334 |
|
} |
335 |
|
} elsif ($comment->{inline} == 0) { |
336 |
|
$ret .= $indentation . $comment->{comment} . "\n"; |
337 |
|
} elsif ($comment->{inline} == 1) { |
338 |
|
if ($same_line) { |
339 |
|
$same_line = 0; |
340 |
|
} else { |
341 |
|
$ret .= $indentation; |
342 |
|
} |
343 |
|
if ($i == @$comments-1) { |
344 |
|
$ret .= "$text " . $comment->{comment} . "\n"; |
345 |
|
$flag = 0; |
346 |
|
} else { |
347 |
|
$ret .= $comment->{comment} . "\n"; |
348 |
|
} |
349 |
|
} |
350 |
|
} |
351 |
} |
} |
352 |
$flag && length($text) and $ret .= $indentation . $text . "\n"; |
$flag && length($text) and $ret .= $indentation . $text . "\n"; |
353 |
$ret; |
$ret; |