Introduction Prerequisites Installation Development Instructions Files Structure Contents Contexts Special Pages Deployment Conclusion

Context for the Templates.

Context in the Templates programming method is the data that would be passed to your templates, after the pieces of the templates have been joined together.

Structs that would be passed to your html files

type HTMLContext struct {
  Page       map[string]string
  Paginator  sites115s.PaginatorStruct
  ToLower    func(string) string
  ToLongDate func(string) string
  ToUpper    func(string) string
  Modulo     func(int, int) int
  Plus       func(int, int) int
  Minus      func(int, int) int
}  
  

Structs that would be passed to your Markdown files

type MDContext struct {
  Page       map[string]string
  HTML       template.HTML
  ToLower    func(string) string
  ToLongDate func(string) string
  ToUpper    func(string) string
  Modulo     func(int, int) int
  Plus       func(int, int) int
  Minus      func(int, int) int
}

Details of the structs above.

Page

Which is of type map[string]string that would contain your page variables.

This is passed to all html pages and markdown pages.

Paginator

Which is declared as

type PaginatorStruct struct {
  Page int
  PaginationCount int
  Pages []map[string]string
  TotalPages int
  TotalPagesArr []int
}
  

Where Pages is a list of Page variables declared above. This Page variables would also contain a url field

Paginator object is passed to the ‘index.html’ and the ‘search_results.html’ pages.

SearchStr

Contains the query for example. s=bank+account

This is passed to the ‘search_results.html’ pages.

HTML

Contains a HTML generated from markdown.

This is passed to the markdown templates.

< Previous Next >