diff options
Diffstat (limited to 'templates/base.qtpl')
| -rw-r--r-- | templates/base.qtpl | 27 | 
1 files changed, 18 insertions, 9 deletions
diff --git a/templates/base.qtpl b/templates/base.qtpl index 566308f..2a42cb8 100644 --- a/templates/base.qtpl +++ b/templates/base.qtpl @@ -1,5 +1,6 @@  This is a base page template. All the other template pages implement this interface. +{% import "context" %}  {% import "strconv" %}  {% import "time" %} @@ -9,10 +10,10 @@ This is a base page template. All the other template pages implement this interf  {% interface  Page { -	Title() -	Content() -    Script() -    Navbar() +	Title(ctx context.Context) +	Content(ctx context.Context) +    Script(ctx context.Context) +    Navbar(ctx context.Context)  }  %} @@ -25,6 +26,8 @@ Page {      }  %} + +  {% code func TimeFormat(t time.Time) string {          return t.Format("02.01.2006")      } @@ -35,24 +38,30 @@ Page {      }  %} +{% code func IsLoggedIn(ctx context.Context) bool { +	t, ok := ctx.Value("logged").(bool) +	return ok && t +    } +%} +  Page prints a page implementing Page interface. -{% func PageTemplate(p Page) %} +{% func PageTemplate(p Page, ctx context.Context) %}  <!DOCTYPE html>  <html lang="en">    <head>      <meta charset="utf-8">      <link rel="icon" href="data:,"> -    <title>{%= p.Title() %}</title>  +    <title>{%= p.Title(ctx) %}</title>       <link rel="stylesheet" href="/static/main{%s Slug %}.css">      <meta content="text/html;charset=utf-8" http-equiv="Content-Type">      <meta name="viewport" content="width=device-width, initial-scale=1" />    </head>    <body> -    {%= p.Navbar() %} +    {%= p.Navbar(ctx) %}      <div class="container"> -      {%= p.Content() %} +      {%= p.Content(ctx) %}      </div>    </body> -  {%= p.Script() %} +  {%= p.Script(ctx) %}  </html>  {% endfunc %}  | 
