gotemplate

package
v3.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2019 License: OSL-3.0 Imports: 17 Imported by: 2

README

Gotemplate

Flamingo comes with a wrapped html/template as simple default template engine.

Refer to golang.org/pkg/html/template/ for the basic documentation

Structured templating

Template directory

This module allows to set up a deeply nested directory structure with template (html) files. These files can be referenced from a controller by just using the path without .html.

For example, to render deep/nested/index.html in your controller, just call

return controller.responder.Render("deep/nested/index")
Layout templates

In addition, a set of base layout templates can be defined in a separate directory. These layout templates can be included into all rendered templates.

If you want to define a site template, just call different sub templates inside like

{{template "content" .}}

In your rendered template, you can call the layout template and define all needed blocks:

{{template "pages/site.html" .}}

{{define "content"}}
  <h1>The site content</h1>
{{end}}

The layout templates can also be used to define common "snippets" which can be used in every rendered template, for example:

{{range $i, $p := .Products}}
  {{if gt $i 0}}
    <hr/>
  {{end}}
  <div class="row">
    {{template "blocks/product.html" $p}}
  </div>
{{end}}

Configuration

gotemplates:
  engine:
    templates:
      basepath: "templates", # template directory
    layout:
      dir: "layouts", #  layout directory within the template directory

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct{}

Module for gotemplate engine

func (*Module) Configure

func (m *Module) Configure(injector *dingo.Injector)

Configure DI

func (*Module) CueConfig added in v3.1.0

func (m *Module) CueConfig() string

CueConfig definition

func (*Module) FlamingoLegacyConfigAlias added in v3.1.0

func (m *Module) FlamingoLegacyConfigAlias() map[string]string

FlamingoLegacyConfigAlias mapping

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL