Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( UserRoot *string DocumentRoot *string )
Blog configuration bindings.
var Funcs = template.FuncMap{ "StringsJoin": strings.Join, "NewlinesToSpace": func(text string) string { return strings.Replace( strings.Replace(text, "\n", " ", -1), "\r", "", -1, ) }, "Now": time.Now, "TrustedMarkdown": func(text string) template.HTML { return template.HTML(markdown.RenderTrustedMarkdown(text)) }, }
Funcs is a global funcmap that the blog can hook its internal methods onto.
Functions ¶
func HasHTMLSuffix ¶
HasHTMLSuffix returns whether the file path will be renderable as HTML for the front-end. Basically, whether it ends with a .gohtml, .html or .md suffix and/or is an index page.
func Template ¶
Template responds with an HTML template.
The vars will be massaged a bit to load the global defaults (such as the website title and user login status), the user's session may be updated with new CSRF token, and other such things. If you just want to render a template without all that nonsense, use RenderPartialTemplate.
func URLFromPath ¶
URLFromPath returns an HTTP path that matches the file path on disk.
For example, given the file path "folder/page.md" it would return the string "/folder/page"
Types ¶
type Filepath ¶
type Filepath struct { // Canonicalized URI version of the file resolved on disk, // possible with a file extension injected. // (i.e. "/about" -> "about.html") URI string Basename string Relative string // Relative path including document root (i.e. "root/about.html") Absolute string // Absolute path on disk (i.e. "/opt/blog/root/about.html") }
Filepath represents a file discovered in the document roots, and maintains both its relative and absolute components.
func ResolvePath ¶
ResolvePath matches a filesystem path to a relative request URI.
This checks the UserRoot first and then the DocumentRoot. This way the user may override templates from the core app's document root.