Generator
Paramtamtam edited this page Jan 28, 2022
·
1 revision
Create a config file (error-pages.yml
) with the following content:
templates:
- path: ./foo.html # Template name "foo" (same as file name),
# content located in the file "foo.html"
- name: bar # Template name "bar", its content is described below:
content: "Error {{ code }}: {{ message }} ({{ description }})"
pages:
400:
message: Bad Request
description: The server did not understand the request
401:
message: Unauthorized
description: The requested page needs a username and a password
Template file foo.html
:
<html>
<title>{{ code }}</title>
<body>
<h1>{{ message }}: {{ description }}</h1>
</body>
</html>
And run the generator:
$ docker run --rm \
-v "$(pwd):/opt:rw" \
-u "$(id -u):$(id -g)" \
tarampampam/error-pages build --config-file ./error-pages.yml ./out
$ tree
.
βββ error-pages.yml
βββ foo.html
βββ out
βββ bar
β βββ 400.html
β βββ 401.html
βββ foo
βββ 400.html
βββ 401.html
3 directories, 6 files
$ cat ./out/foo/400.html
<html>
<title>400</title>
<body>
<h1>Bad Request: The server did not understand the request</h1>
</body>
</html>
$ cat ./out/bar/400.html
Error 400: Bad Request (The server did not understand the request)
To see the usage help run the following command:
$ docker run --rm tarampampam/error-pages build --help