Skip to content

Commit

Permalink
fix: Add temporary templates to fix Docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT2 committed Sep 25, 2021
1 parent d007495 commit 791103b
Show file tree
Hide file tree
Showing 8 changed files with 766 additions and 0 deletions.
31 changes: 31 additions & 0 deletions templates/basepage.qtpl
@@ -0,0 +1,31 @@
This is a base page template. All the other template pages implement this interface.

{% interface
Page {
Title()
Body()
}
%}


Page prints a page implementing Page interface.
{% func PageTemplate(p Page) %}
<html>
<head>
<title>{%= p.Title() %}</title>
</head>
<body>
<div>
<a href="/">return to main page</a>
</div>
{%= p.Body() %}
</body>
</html>
{% endfunc %}


Base page implementation. Other pages may inherit from it if they need
overriding only certain Page methods
{% code type BasePage struct {} %}
{% func (p *BasePage) Title() %}This is a base title{% endfunc %}
{% func (p *BasePage) Body() %}This is a base body{% endfunc %}
165 changes: 165 additions & 0 deletions templates/basepage.qtpl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions templates/errorpage.qtpl
@@ -0,0 +1,20 @@
// Error page template. Implements BasePage methods.

{% code
type ErrorPage struct {
// inherit from base page, so its' title is used in error page.
BasePage

// error path
Path []byte
}
%}


{% func (p *ErrorPage) Body() %}
<h1>Error page</h1>
</div>
Unsupported path <b>{%z p.Path %}</b>.
</div>
Base page body: {%= p.BasePage.Body() %}
{% endfunc %}
77 changes: 77 additions & 0 deletions templates/errorpage.qtpl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions templates/mainpage.qtpl
@@ -0,0 +1,31 @@
// Main page template. Implements BasePage methods.

{% import "github.com/valyala/fasthttp" %}

{% code
type MainPage struct {
CTX *fasthttp.RequestCtx
}
%}


{% func (p *MainPage) Title() %}
This is the main page
{% endfunc %}


{% func (p *MainPage) Body() %}
<h1>Main page</h1>
<div>
Click links below:
<ul>
<li><a href="/table?rowsCount=42">Table page</a></li>
<li><a href="/unknown-page">Error page</a></li>
</ul>
</div>
<div>
Some info about you:<br/>
IP: <b>{%s p.CTX.RemoteIP().String() %}</b><br/>
User-Agent: <b>{%z p.CTX.UserAgent() %}</b><br/>
</div>
{% endfunc %}

0 comments on commit 791103b

Please sign in to comment.