]> mj.ucw.cz Git - temple.git/blobdiff - UCW/Temple.pm
The argument of UCW::Temple::start() is no longer mandatory
[temple.git] / UCW / Temple.pm
index ff7141072483e62abb191fdf2c062e2d432f2387..1a3dc971f10f5980da10ccbdea2458d3151db1f3 100644 (file)
@@ -24,6 +24,12 @@ sub out {
        return;
 }
 
+our %deps = ();
+
+sub add_depend($) {
+       $deps{$_[0]} = 1;
+}
+
 sub get_nested($$$) {
        my ($r,$left,$right) = @_;
        pos $$r = pos($$r)-1;
@@ -100,7 +106,7 @@ sub parse_string($) {
                } elsif ($t =~ /\G\@#[^\n]*\n/cgs) {
                        # a comment, which is ignored
                } elsif ($t =~ /\G\@\@/cgs) {
-                       out "\@";
+                       out "\@" if $cond[0] > 0;
                } elsif ($t =~ /\G\@{/cgs) {
                        my $x = get_nested(\$t, "{", "}");
                        out eval_if_ok($x);
@@ -134,6 +140,7 @@ sub parse_string($) {
 
 sub parse_file($) {
        my ($name) = @_;
+       add_depend($name);
        my $fh = new IO::File $name;
        die "Unable to open $name: $!" unless defined $fh;
        my $text;
@@ -142,7 +149,7 @@ sub parse_file($) {
        parse_string($text);
 }
 
-sub start($)
+sub start(;$)
 {
        $arguments = $_[0];
        @cond = (1);
@@ -190,6 +197,7 @@ sub include {
 sub load {
        my $f = shift @_;
        (!defined($f) || @_) and die "\@load requires only one argument";
+       UCW::Temple::add_depend($f);
        require $f;
        return;
 }