import (
_fmt "fmt"
+
"github.com/gohugoio/hugo/helpers"
)
return _fmt.Sprintln(a...)
}
+// Errorf formats according to a format specifier and returns the string as a
+// value that satisfies error.
func (ns *Namespace) Errorf(format string, a ...interface{}) string {
ns.errorLogger.Printf(format, a...)
return _fmt.Sprintf(format, a...)
"github.com/gohugoio/hugo/deps"
)
+// TemplateFuncsNamespaceRegistry describes a registry of functions that provide
+// namespaces.
var TemplateFuncsNamespaceRegistry []func(d *deps.Deps) *TemplateFuncsNamespace
+// AddTemplateFuncsNamespace adds a given function to a registry.
func AddTemplateFuncsNamespace(ns func(d *deps.Deps) *TemplateFuncsNamespace) {
TemplateFuncsNamespaceRegistry = append(TemplateFuncsNamespaceRegistry, ns)
}
+// TemplateFuncsNamespace represents a template function namespace.
type TemplateFuncsNamespace struct {
// The namespace name, "strings", "lang", etc.
Name string
MethodMappings map[string]TemplateFuncMethodMapping
}
+// TemplateFuncsNamespaces is a slice of TemplateFuncsNamespace.
type TemplateFuncsNamespaces []*TemplateFuncsNamespace
+// AddMethodMapping adds a method to a template function namespace.
func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []string, examples [][2]string) {
if t.MethodMappings == nil {
t.MethodMappings = make(map[string]TemplateFuncMethodMapping)
}
+// TemplateFuncMethodMapping represents a mapping of functions to methods for a
+// given namespace.
type TemplateFuncMethodMapping struct {
Method interface{}
return buf.Bytes(), nil
}
+// MarshalJSON returns the JSON encoding of namespaces.
func (namespaces TemplateFuncsNamespaces) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
deps *deps.Deps
}
-// Translate ...
+// Translate returns a translated string for id.
func (ns *Namespace) Translate(id interface{}, args ...interface{}) (string, error) {
sid, err := cast.ToStringE(id)
if err != nil {
MergeByLanguageInterface(other interface{}) (interface{}, error)
}
+// Merge creates a union of pages from two languages.
func (ns *Namespace) Merge(p2, p1 interface{}) (interface{}, error) {
merger, ok := p1.(pagesLanguageMerger)
if !ok {
## Build Templates
-If you add or modify any template in the tmplates folder, you also need to run `mage generate` to get the Go code in synch.
\ No newline at end of file
+If you add or modify any template in the templates folder, you also need to run `mage generate` to get the Go code in synch.
// Package embedded defines the internal templates that Hugo provides.
package embedded
+// EmbeddedTemplates represents all embedded templates.
var EmbeddedTemplates = [][2]string{
`)
// Package embedded defines the internal templates that Hugo provides.
package embedded
+// EmbeddedTemplates represents all embedded templates.
var EmbeddedTemplates = [][2]string{
{`_default/robots.txt`, `User-agent: *`},
{`_default/rss.xml`, `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">