Documentation
¶
Index ¶
Constants ¶
View Source
const ( // The default order by field for the list function. OrderBy = "created_at" // The default order direction field for the list function. OrderDirection = "desc" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace defines the methods for posts to be used as template functions.
func (*Namespace) Find ¶
func (ns *Namespace) Find(id interface{}) interface{}
Find
Obtains the post by ID and returns a domain.PostDatum type or nil if not found.
Example: {{ post 123 }}
func (*Namespace) List ¶
List
Accepts a dict (map[string]interface{}) and returns an array of domain.post. It sets defaults if some of the param arguments are missing, and returns an error if the data could not be marshalled.
Returns errors.TEMPLATE if the template post params failed to parse.
Example: {{ $result := post (dict "limit" 10 "resource" "posts") }} {{ with $result.Posts }}
{{ range $post := . }} <h2>{{ $post.Title }}</h2> <a href="{{ $post.Slug }}">Read more</a> {{ end }} {{ else }} <h4>No posts found</h4>
{{ end }}
type Posts ¶
type Posts struct { Posts []domain.PostTemplate Pagination *pagination.Pagination }
Posts defines the struct for returning posts and pagination back to the template.
Click to show internal directories.
Click to hide internal directories.