Modularise templates
This commit is contained in:
parent
dc7631ede2
commit
d27625f112
16
templates/base.html
Normal file
16
templates/base.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta name="charset" content="utf-8" />
|
||||||
|
<title>barcodes</title>
|
||||||
|
<!-- CSS and JS Inclusions -->
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta name="author" content="Frederick Boniface" />
|
||||||
|
<meta name="description" content="Easily create a variety of barcodes" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>{{ template "title" }}</h1>
|
||||||
|
{{ template "body" . }}
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,12 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
{{ define "title" }}API Documentation{{ end }}
|
||||||
<html lang="en">
|
{{ define "body" }}
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>API Documentation</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>API Requests</h1>
|
|
||||||
|
|
||||||
<p>API Requests can be made by making a POST request to /generate</p>
|
<p>API Requests can be made by making a POST request to /generate</p>
|
||||||
|
|
||||||
<p>The request body should be JSON similar to the below</p>
|
<p>The request body should be JSON similar to the below</p>
|
||||||
@ -37,5 +30,4 @@
|
|||||||
<p><code>content</code> should be the value you wish the barcode to display. This should be a string and may not accept all characters - that is dependent on the barcode type.</p>
|
<p><code>content</code> should be the value you wish the barcode to display. This should be a string and may not accept all characters - that is dependent on the barcode type.</p>
|
||||||
|
|
||||||
<p>The response will be a PNG image</p>
|
<p>The response will be a PNG image</p>
|
||||||
</body>
|
{{ end }}
|
||||||
</html>
|
|
@ -22,7 +22,7 @@ func helpTemplate(w http.ResponseWriter, r *http.Request) {
|
|||||||
BarcodeOptions: barcodeOptions,
|
BarcodeOptions: barcodeOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl := template.Must(template.New("help.html").ParseFiles("templates/help.html"))
|
tmpl := template.Must(template.New("base.html").ParseFiles("templates/base.html", "templates/help.html"))
|
||||||
|
|
||||||
err := tmpl.Execute(w, data)
|
err := tmpl.Execute(w, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user