-# replaced the Perl one-liner with shell logic to remove the dependency
-# cat src/layout.html | perl -pe'use File::Slurper qw(read_text); s/\@include\((.+?)\)/read_text($1)/eg' > /tmp/included.html
-
-cat src/layout.html | grep -v '</body>' | grep -v '</html>' | sed -e 's/BODYID/search-page/' > dist/search.html
-echo '<script id="searchpage-template" type="text/x-handlebars-template">' >> dist/search.html
-cat src/templates/searchpage.hbs >> dist/search.html
-echo '</script>' >> dist/search.html
-echo '</body>' >> dist/search.html
-echo '</html>' >> dist/search.html
-
-cat src/layout.html | grep -v '</body>' | grep -v '</html>' | sed -e 's/BODYID/reverse-page/' > dist/reverse.html
-echo '<script id="reversepage-template" type="text/x-handlebars-template">' >> dist/reverse.html
-cat src/templates/reversepage.hbs >> dist/reverse.html
-echo '</script>' >> dist/reverse.html
-echo '</body>' >> dist/reverse.html
-echo '</html>' >> dist/reverse.html
-
-cat src/layout.html | grep -v '</body>' | grep -v '</html>' | sed -e 's/BODYID/details-page/' > dist/details.html
-echo '<script id="detailspage-template" type="text/x-handlebars-template">' >> dist/details.html
-cat src/templates/detailspage.hbs >> dist/details.html
-echo '</script>' >> dist/details.html
-echo '<script id="detailspage-index-template" type="text/x-handlebars-template">' >> dist/details.html
-cat src/templates/detailspage-index.hbs >> dist/details.html
-echo '</script>' >> dist/details.html
-echo '</body>' >> dist/details.html
-echo '</html>' >> dist/details.html
-
-cat src/layout.html | grep -v '</body>' | grep -v '</html>' | sed -e 's/BODYID/deletable-page/' > dist/deletable.html
-echo '<script id="deletable-template" type="text/x-handlebars-template">' >> dist/deletable.html
-cat src/templates/deletable.hbs >> dist/deletable.html
-echo '</script>' >> dist/deletable.html
-echo '</body>' >> dist/deletable.html
-echo '</html>' >> dist/deletable.html
-
-cat src/layout.html | grep -v '</body>' | grep -v '</html>' | sed -e 's/BODYID/polygons-page/' > dist/polygons.html
-echo '<script id="polygons-template" type="text/x-handlebars-template">' >> dist/polygons.html
-cat src/templates/polygons.hbs >> dist/polygons.html
-echo '</script>' >> dist/polygons.html
-echo '</body>' >> dist/polygons.html
-echo '</html>' >> dist/polygons.html
+{
+ cat src/layout.html | grep -v '</body>' | grep -v '</html>'
+ echo '<script id="searchpage-template" type="text/x-handlebars-template">'
+ cat src/templates/searchpage.hbs
+ echo '</script>'
+
+ echo '<script id="reversepage-template" type="text/x-handlebars-template">'
+ cat src/templates/reversepage.hbs
+ echo '</script>'
+
+ echo '<script id="detailspage-template" type="text/x-handlebars-template">'
+ cat src/templates/detailspage.hbs
+ echo '</script>'
+
+ echo '<script id="detailspage-index-template" type="text/x-handlebars-template">'
+ cat src/templates/detailspage-index.hbs
+ echo '</script>'
+
+ echo '<script id="deletable-template" type="text/x-handlebars-template">'
+ cat src/templates/deletable.hbs
+ echo '</script>'
+
+ echo '<script id="polygons-template" type="text/x-handlebars-template">'
+ cat src/templates/polygons.hbs
+ echo '</script>'
+
+ echo '</body>'
+ echo '</html>'
+} > dist/search.html
+
+cp dist/search.html dist/reverse.html
+cp dist/search.html dist/details.html
+cp dist/search.html dist/deletable.html
+cp dist/search.html dist/polygons.html