Skip to content

Commit

Permalink
copy-nix-dev-tutorials: use printf to fix title
Browse files Browse the repository at this point in the history
The title was using what amounted to:

   echo '[% $title %]' > file.tt

Which put the literal `$title` perl variable, which in Template Toolkit,
an undefined variable is equivalent to an empty string.

This made the <title /> of the page be "NixOS - Guides - ".

This fixes that by using the better `printf` building for building
strings to print.

Additionally we can drop the empty echoes and use `\n` as printf honours
them.
  • Loading branch information
samueldr committed Sep 10, 2020
1 parent 0be95e6 commit 8e8ccec
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions copy-nix-dev-tutorials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ for page in "${pages[@]}"; do

echo "<li><a href=\"/$outDir/$filename.html\">$title</a></li>" >> learn_guides.html.in

echo '[% WRAPPER layout.tt title="Guides - $title" %]' > $target
echo '' >> $target
printf '[%% WRAPPER layout.tt title="Guides - %s" %%]\n\n' "$title" > $target

xidel $source --css '.body > *' --printed-node-format=html \
| sed 's|<a class=\"headerlink\".*<\/a>||g' \
Expand All @@ -37,6 +36,5 @@ for page in "${pages[@]}"; do
| sed 's|../reference/pinning-nixpkgs.html#ref-pinning-nixpkgs|towards-reproducibility-pinning-nixpkgs.html|g' \
>> "$target"

echo '' >> $target
echo "[% END %]" >> $target
printf '\n\n[%% END %%]\n' >> $target
done

0 comments on commit 8e8ccec

Please sign in to comment.