mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
9aee8ace4e
commit
a432c90aee
3 changed files with 44 additions and 5 deletions
43
tpl/images/init.go
Normal file
43
tpl/images/init.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
// Copyright 2017 The Hugo Authors. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package images
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/hugo/deps"
|
||||||
|
"github.com/spf13/hugo/tpl/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
const name = "images"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
f := func(d *deps.Deps) *internal.TemplateFuncsNamespace {
|
||||||
|
ctx := New(d)
|
||||||
|
|
||||||
|
examples := [][2]string{
|
||||||
|
{},
|
||||||
|
}
|
||||||
|
|
||||||
|
return &internal.TemplateFuncsNamespace{
|
||||||
|
Name: name,
|
||||||
|
Context: func() interface{} { return ctx },
|
||||||
|
Aliases: map[string]interface{}{
|
||||||
|
"imageConfig": ctx.Config,
|
||||||
|
},
|
||||||
|
Examples: examples,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal.AddTemplateFuncsNamespace(f)
|
||||||
|
}
|
|
@ -21,7 +21,6 @@ import (
|
||||||
|
|
||||||
bp "github.com/spf13/hugo/bufferpool"
|
bp "github.com/spf13/hugo/bufferpool"
|
||||||
"github.com/spf13/hugo/deps"
|
"github.com/spf13/hugo/deps"
|
||||||
"github.com/spf13/hugo/tpl/images"
|
|
||||||
"github.com/spf13/hugo/tpl/inflect"
|
"github.com/spf13/hugo/tpl/inflect"
|
||||||
"github.com/spf13/hugo/tpl/os"
|
"github.com/spf13/hugo/tpl/os"
|
||||||
"github.com/spf13/hugo/tpl/safe"
|
"github.com/spf13/hugo/tpl/safe"
|
||||||
|
@ -36,7 +35,6 @@ type templateFuncster struct {
|
||||||
cachedPartials partialCache
|
cachedPartials partialCache
|
||||||
|
|
||||||
// Namespaces
|
// Namespaces
|
||||||
images *images.Namespace
|
|
||||||
inflect *inflect.Namespace
|
inflect *inflect.Namespace
|
||||||
os *os.Namespace
|
os *os.Namespace
|
||||||
safe *safe.Namespace
|
safe *safe.Namespace
|
||||||
|
@ -53,7 +51,6 @@ func newTemplateFuncster(deps *deps.Deps) *templateFuncster {
|
||||||
cachedPartials: partialCache{p: make(map[string]interface{})},
|
cachedPartials: partialCache{p: make(map[string]interface{})},
|
||||||
|
|
||||||
// Namespaces
|
// Namespaces
|
||||||
images: images.New(deps),
|
|
||||||
inflect: inflect.New(),
|
inflect: inflect.New(),
|
||||||
os: os.New(deps),
|
os: os.New(deps),
|
||||||
safe: safe.New(),
|
safe: safe.New(),
|
||||||
|
|
|
@ -29,6 +29,7 @@ import (
|
||||||
_ "github.com/spf13/hugo/tpl/crypto"
|
_ "github.com/spf13/hugo/tpl/crypto"
|
||||||
_ "github.com/spf13/hugo/tpl/data"
|
_ "github.com/spf13/hugo/tpl/data"
|
||||||
_ "github.com/spf13/hugo/tpl/encoding"
|
_ "github.com/spf13/hugo/tpl/encoding"
|
||||||
|
_ "github.com/spf13/hugo/tpl/images"
|
||||||
_ "github.com/spf13/hugo/tpl/lang"
|
_ "github.com/spf13/hugo/tpl/lang"
|
||||||
_ "github.com/spf13/hugo/tpl/math"
|
_ "github.com/spf13/hugo/tpl/math"
|
||||||
_ "github.com/spf13/hugo/tpl/strings"
|
_ "github.com/spf13/hugo/tpl/strings"
|
||||||
|
@ -85,7 +86,6 @@ func (t *templateFuncster) partialCached(name string, context interface{}, varia
|
||||||
func (t *templateFuncster) initFuncMap() {
|
func (t *templateFuncster) initFuncMap() {
|
||||||
funcMap := template.FuncMap{
|
funcMap := template.FuncMap{
|
||||||
// Namespaces
|
// Namespaces
|
||||||
"images": t.images.Namespace,
|
|
||||||
"inflect": t.inflect.Namespace,
|
"inflect": t.inflect.Namespace,
|
||||||
"os": t.os.Namespace,
|
"os": t.os.Namespace,
|
||||||
"safe": t.safe.Namespace,
|
"safe": t.safe.Namespace,
|
||||||
|
@ -102,7 +102,6 @@ func (t *templateFuncster) initFuncMap() {
|
||||||
"htmlEscape": t.transform.HTMLEscape,
|
"htmlEscape": t.transform.HTMLEscape,
|
||||||
"htmlUnescape": t.transform.HTMLUnescape,
|
"htmlUnescape": t.transform.HTMLUnescape,
|
||||||
"humanize": t.inflect.Humanize,
|
"humanize": t.inflect.Humanize,
|
||||||
"imageConfig": t.images.Config,
|
|
||||||
"int": func(v interface{}) (int, error) { return cast.ToIntE(v) },
|
"int": func(v interface{}) (int, error) { return cast.ToIntE(v) },
|
||||||
"markdownify": t.transform.Markdownify,
|
"markdownify": t.transform.Markdownify,
|
||||||
"now": t.time.Now,
|
"now": t.time.Now,
|
||||||
|
|
Loading…
Reference in a new issue