chiark / gitweb /
die: Prepare for extracting text template too (2)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 15 Apr 2022 22:40:31 +0000 (23:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 15 Apr 2022 22:40:31 +0000 (23:40 +0100)
Bracket our cooldown output all together.

I did it the other way because I had forgotten that the output order
is controlled by the script, not the input.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dice/overlay-template-extractor

index 3ca02b8f9cc0340dfbc46cfc45d47f3c615923f6..168cf324ff0e72790682cf5127252cb37a496d1f 100755 (executable)
@@ -15,7 +15,9 @@ my $xpc = XML::LibXML::XPathContext->new($dom) or die;
 
 our ($label, $node);
 
-print "<!--made by dice/cooldown-template-extractor-->\n" or die $!;
+sub p { print @_ or die $!; }
+
+p "<!--made by dice/cooldown-template-extractor-->\n";
 
 sub process_node ($$) {
   my $fn;
@@ -24,10 +26,7 @@ sub process_node ($$) {
   die "$label ?" unless @$nodes == 1;
   $node = $nodes->[0];
   $fn->($node);
-  print
-    "{% if cooldown_active %}",
-    $node->toString,
-    "{% endif %}\n" or die $!;
+  p $node->toString, "\n";
 }
 
 our $nom_radius;
@@ -56,6 +55,7 @@ sub filter_circle () {
   $node->setAttribute('r', "{{radius}}");
 }
 
+p "{% if cooldown_active %}\n";
 process_node('timeblack', sub {
   $nom_radius = $node->getAttribute('r');
   filter_circle();
@@ -69,3 +69,4 @@ process_node('timegrey', sub {
     $node->setAttribute("data-$d", "{{$d}}");
   }
 });
+p "{% endif %}\n";