tdewolff:
css:
inline: false
- keepCSS2: false
precision: 0
version: 0
html:
keepNumbers: false
precision: 0
svg:
- inline: false
keepComments: false
precision: 0
xml:
disable: false
googleAnalytics:
disable: false
- respectDoNotTrack: false
+ respectDoNotTrack: true
instagram:
disable: false
simple: false
- '[a f]'
D:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - seed
+ - 'n'
+ - hi
+ Description: 'D returns a sorted slice of unique random integers in the half-open interval\n[0, hi) using the provided seed value. The number of elements in the\nresulting slice is n or hi, whichever is less.\n\nIf n <= hi, it returns a sorted random sample of size n using J. S. Vitter’s\nMethod D for sequential random sampling.\n\nIf n > hi, it returns the full, sorted range [0, hi) of size hi.\n\nIf n == 0 or hi == 0, it returns an empty slice.\n\nReference:\n\n\tJ. S. Vitter, "An efficient algorithm for sequential random sampling," ACM Trans. Math. Softw., vol. 11, no. 1, pp. 37–57, 1985.\n\tSee also: https://getkerf.wordpress.com/2016/03/30/the-best-algorithm-no-one-knows-about/'
+ Examples: []
Delimit:
Aliases:
- delimit
- bar=2&foo=1
Reverse:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - l
+ Description: Reverse creates a copy of the list l and reverses it.
+ Examples: []
Seq:
Aliases:
- seq
Examples: []
LtCollate:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - collator
+ - first
+ - others
+ Description: |-
+ LtCollate returns the boolean truth of arg1 < arg2 && arg1 < arg3 && arg1 < arg4.
+ The provided collator will be used for string comparisons.
+ This is for internal use.
+ Examples: []
Ne:
Aliases:
- ne
crypto:
FNV32a:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - v
+ Description: 'FNV32a hashes v using fnv32a algorithm.\n<docsmeta>{"newIn": "0.98.0" }</docsmeta>'
+ Examples: []
HMAC:
Aliases:
- hmac
Examples: []
Quoted:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - v
+ Description: Quoted returns a string that needs to be quoted in CSS.
+ Examples: []
Sass:
Aliases:
- toCSS
Examples: []
TailwindCSS:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - args
+ Description: TailwindCSS processes the given Resource with tailwindcss.
+ Examples: []
Unquoted:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - v
+ Description: Unquoted returns a string that does not need to be quoted in CSS.
+ Examples: []
data:
GetCSV:
Aliases:
- '{\n "Hugo": "Rocks!"\n}'
TestDeprecationErr:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - item
+ - alternative
+ Description: Internal template func, used in tests only.
+ Examples: []
TestDeprecationInfo:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - item
+ - alternative
+ Description: Internal template func, used in tests only.
+ Examples: []
TestDeprecationWarn:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - item
+ - alternative
+ Description: Internal template func, used in tests only.
+ Examples: []
Timer:
Aliases: null
- Args: null
+ Args:
+ - name
Description: ''
- Examples: null
+ Examples: []
VisualizeSpaces:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - val
+ Description: VisualizeSpaces returns a string with spaces replaced by a visible string.
+ Examples: []
diagrams:
Goat:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - v
+ Description: Goat creates a new SVG diagram from input v.
+ Examples: []
encoding:
Base64Decode:
Aliases:
- ''
Errormf:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - m
+ - format
+ - args
+ Description: Errormf is experimental and subject to change at any time.
+ Examples: []
Print:
Aliases:
- print
- ''
Warnmf:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - m
+ - format
+ - args
+ Description: Warnmf is experimental and subject to change at any time.
+ Examples: []
hash:
FNV32a:
Aliases: null
Examples: null
Filter:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - args
+ Description: Filter applies the given filters to the image given as the last element in args.
+ Examples: []
Gamma:
Aliases: null
Args: null
Examples: null
QR:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - args
+ Description: |-
+ QR encodes the given text into a QR code using the specified options,
+ returning an image resource.
+ Examples: []
Saturation:
Aliases: null
Args: null
Examples: []
Batch:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - id
+ Description: |-
+ Batch creates a new Batcher with the given ID.
+ Repeated calls with the same ID will return the same Batcher.
+ The ID will be used to name the root directory of the batch.
+ Forward slashes in the ID is allowed.
+ Examples: []
Build:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - args
+ Description: Build processes the given Resource with ESBuild.
+ Examples: []
lang:
FormatAccounting:
Aliases: null
- 512.50%
Merge:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - p2
+ - p1
+ Description: Merge creates a union of pages from two languages.
+ Examples: []
Translate:
Aliases:
- i18n
Counter:
Aliases: null
Args: null
- Description: ''
- Examples: null
+ Description: 'Counter increments and returns a global counter.\nThis was originally added to be used in tests where now.UnixNano did not\nhave the needed precision (especially on Windows).\nNote that given the parallel nature of Hugo, you cannot use this to get sequences of numbers,\nand the counter will reset on new builds.\n<docsmeta>{"identifiers": ["now.UnixNano"] }</docsmeta>'
+ Examples: []
Div:
Aliases:
- div
- '8'
Product:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - inputs
+ Description: Product returns the product of all numbers in inputs. Any slices in inputs are flattened.
+ Examples: []
Rand:
Aliases: null
Args: null
- '1'
Sum:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - inputs
+ Description: Sum returns the sum of all numbers in inputs. Any slices in inputs are flattened.
+ Examples: []
Tan:
Aliases: null
Args:
- Hugo Rocks!
Stat:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - i
+ Description: Stat returns the os.FileInfo structure describing file.
+ Examples: []
partials:
Include:
Aliases:
path:
Base:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - path
+ Description: |-
+ Base returns the last element of path.
+ Trailing slashes are removed before extracting the last element.
+ If the path is empty, Base returns ".".
+ If the path consists entirely of slashes, Base returns "/".
+ The input path is passed into filepath.ToSlash converting any Windows slashes
+ to forward slashes.
+ Examples: []
BaseName:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - path
+ Description: |-
+ BaseName returns the last element of path, removing the extension if present.
+ Trailing slashes are removed before extracting the last element.
+ If the path is empty, Base returns ".".
+ If the path consists entirely of slashes, Base returns "/".
+ The input path is passed into filepath.ToSlash converting any Windows slashes
+ to forward slashes.
+ Examples: []
Clean:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - path
+ Description: |-
+ Clean replaces the separators used with standard slashes and then
+ extraneous slashes are removed.
+ Examples: []
Dir:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - path
+ Description: |-
+ Dir returns all but the last element of path, typically the path's directory.
+ After dropping the final element using Split, the path is Cleaned and trailing
+ slashes are removed.
+ If the path is empty, Dir returns ".".
+ If the path consists entirely of slashes followed by non-slash bytes, Dir
+ returns a single slash. In any other case, the returned path does not end in a
+ slash.
+ The input path is passed into filepath.ToSlash converting any Windows slashes
+ to forward slashes.
+ Examples: []
Ext:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - path
+ Description: |-
+ Ext returns the file name extension used by path.
+ The extension is the suffix beginning at the final dot
+ in the final slash-separated element of path;
+ it is empty if there is no dot.
+ The input path is passed into filepath.ToSlash converting any Windows slashes
+ to forward slashes.
+ Examples: []
Join:
Aliases: null
Args:
resources:
Babel:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - args
+ Description: 'Babel processes the given Resource with Babel.\nDeprecated: Moved to the js namespace in Hugo 0.128.0.'
+ Examples: []
ByType:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - typ
+ Description: ByType returns resources of a given resource type (e.g. "image").
+ Examples: []
Concat:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - targetPathIn
+ - r
+ Description: |-
+ Concat concatenates a slice of Resource objects. These resources must
+ (currently) be of the same Media Type.
+ Examples: []
Copy:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - s
+ - r
+ Description: Copy copies r to the new targetPath in s.
+ Examples: []
ExecuteAsTemplate:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - ctx
+ - args
+ Description: |-
+ ExecuteAsTemplate creates a Resource from a Go template, parsed and executed with
+ the given data, and published to the relative target path.
+ Examples: []
Fingerprint:
Aliases:
- fingerprint
Examples: []
FromString:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - targetPathIn
+ - contentIn
+ Description: FromString creates a Resource from a string published to the relative target path.
+ Examples: []
Get:
Aliases: null
Args:
Examples: []
Match:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - pattern
+ Description: |-
+ Match gets all resources matching the given base path prefix, e.g
+ "*.png" will match all png files. The "*" does not match path delimiters (/),
+ so if you organize your resources in sub-folders, you need to be explicit about it, e.g.:
+ "images/*.png". To match any PNG image anywhere in the bundle you can do "**.png", and
+ to match all PNG images below the images folder, use "images/**.jpg".
+
+ The matching is case insensitive.
+
+ Match matches by using the files name with path relative to the file system root
+ with Unix style slashes (/) and no leading slash, e.g. "images/logo.png".
+
+ See https://github.com/gobwas/glob for the full rules set.
+
+ It looks for files in the assets file system.
+
+ See Match for a more complete explanation about the rules used.
+ Examples: []
Minify:
Aliases:
- minify
Examples: []
PostCSS:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - args
+ Description: 'PostCSS processes the given Resource with PostCSS.\nDeprecated: Moved to the css namespace in Hugo 0.128.0.'
+ Examples: []
PostProcess:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - r
+ Description: PostProcess processes r after the build.
+ Examples: []
ToCSS:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - args
+ Description: 'ToCSS converts the given Resource to CSS. You can optional provide an Options object\nas second argument. As an option, you can e.g. specify e.g. the target path (string)\nfor the converted CSS resource.\nDeprecated: Moved to the css namespace in Hugo 0.128.0.'
+ Examples: []
safe:
CSS:
Aliases:
- 'false'
ContainsNonSpace:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - s
+ Description: 'ContainsNonSpace reports whether s contains any non-space characters as defined\nby Unicode''s White Space property,\n<docsmeta>{"newIn": "0.111.0" }</docsmeta>'
+ Examples: []
Count:
Aliases: null
Args:
Examples: []
Diff:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - oldname
+ - old
+ - newname
+ - new
+ Description: |-
+ Diff returns an anchored diff of the two texts old and new in the “unified
+ diff” format. If old and new are identical, Diff returns an empty string.
+ Examples: []
FindRE:
Aliases:
- findRE
- aabb
TrimSpace:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - s
+ Description: |-
+ TrimSpace returns the given string, removing leading and trailing whitespace
+ as defined by Unicode.
+ Examples: []
TrimSuffix:
Aliases: null
Args:
templates:
Current:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - ctx
+ Description: Get information about the currently executing template.
+ Examples: []
Defer:
Aliases: null
Args:
Note that this is the Unix-styled relative path including filename suffix,
e.g. partials/header.html
Examples:
- - - '{{ if (templates.Exists "partials/header.html") }}Yes!{{ end }}'
+ - - '{{ if (templates.Exists "_partials/header.html") }}Yes!{{ end }}'
- Yes!
- - - '{{ if not (templates.Exists "partials/doesnotexist.html") }}No!{{ end }}'
+ - - '{{ if not (templates.Exists "_partials/doesnotexist.html") }}No!{{ end }}'
- No!
time:
AsTime:
- 'dateFormat: Wednesday, Jan 21, 2015'
In:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - timeZoneName
+ - t
+ Description: |-
+ In returns the time t in the IANA time zone specified by timeZoneName.
+ If timeZoneName is "" or "UTC", the time is returned in UTC.
+ If timeZoneName is "Local", the time is returned in the system's local time zone.
+ Otherwise, timeZoneName must be a valid IANA location name (e.g., "Europe/Oslo").
+ Examples: []
Now:
Aliases:
- now
transform:
CanHighlight:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - language
+ Description: CanHighlight returns whether the given code language is supported by the Chroma highlighter.
+ Examples: []
Emojify:
Aliases:
- emojify
- Cathal Garvey & The Sunshine Band <cathal@foo.bar>
HTMLToMarkdown:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - ctx
+ - args
+ Description: |-
+ This was added in Hugo v0.151.0 and should be considered experimental for now.
+ We need to test this out in the wild for a while before committing to this API,
+ and there will eventually be more options here.
+ Examples: []
HTMLUnescape:
Aliases:
- htmlUnescape
Examples: []
HighlightCodeBlock:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - ctx
+ - opts
+ Description: HighlightCodeBlock highlights a code block on the form received in the codeblock render hooks.
+ Examples: []
Markdownify:
Aliases:
- markdownify
- Hello world, gophers!
PortableText:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - v
+ Description: |-
+ PortableText converts the portable text in v to Markdown.
+ We may add more options in the future.
+ Examples: []
Remarshal:
Aliases: null
Args:
- '{\n "title": "Hello World"\n}\n'
ToMath:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - ctx
+ - args
+ Description: |-
+ ToMath converts a LaTeX string to math in the given format, default MathML.
+ This uses KaTeX to render the math, see https://katex.org/.
+ Examples: []
Unmarshal:
Aliases:
- unmarshal
- a/b
Parse:
Aliases: null
- Args: null
- Description: ''
- Examples: null
+ Args:
+ - rawurl
+ Description: |-
+ Parse parses rawurl into a URL structure. The rawurl may be relative or
+ absolute.
+ Examples: []
+ PathEscape:
+ Aliases: null
+ Args:
+ - s
+ Description: |-
+ PathEscape returns the given string, applying percent-encoding to special
+ characters and reserved delimiters so it can be safely used as a segment
+ within a URL path.
+ Examples: []
+ PathUnescape:
+ Aliases: null
+ Args:
+ - s
+ Description: |-
+ PathUnescape returns the given string, replacing all percent-encoded
+ sequences with the corresponding unescaped characters.
+ Examples: []
Ref:
Aliases:
- ref
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
+ ns.AddMethodMapping(ctx.ToFloat,
+ []string{"float"},
+ [][2]string{
+ {`{{ "1234" | float | printf "%T" }}`, `float64`},
+ },
+ )
+
ns.AddMethodMapping(ctx.ToInt,
[]string{"int"},
[][2]string{
},
)
- ns.AddMethodMapping(ctx.ToFloat,
- []string{"float"},
- [][2]string{
- {`{{ "1234" | float | printf "%T" }}`, `float64`},
- },
- )
-
return ns
}
[][2]string{},
)
+ ns.AddMethodMapping(ctx.Append,
+ []string{"append"},
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.Apply,
[]string{"apply"},
[][2]string{},
},
)
- ns.AddMethodMapping(ctx.SymDiff,
- []string{"symdiff"},
- [][2]string{
- {`{{ slice 1 2 3 | symdiff (slice 3 4) }}`, `[1 2 4]`},
- },
+ ns.AddMethodMapping(ctx.D,
+ nil,
+ [][2]string{},
)
ns.AddMethodMapping(ctx.Delimit,
[][2]string{},
)
- ns.AddMethodMapping(ctx.KeyVals,
- []string{"keyVals"},
- [][2]string{
- {`{{ keyVals "key" "a" "b" }}`, `key: [a b]`},
- },
+ ns.AddMethodMapping(ctx.Group,
+ []string{"group"},
+ [][2]string{},
)
ns.AddMethodMapping(ctx.In,
[][2]string{},
)
+ ns.AddMethodMapping(ctx.KeyVals,
+ []string{"keyVals"},
+ [][2]string{
+ {`{{ keyVals "key" "a" "b" }}`, `key: [a b]`},
+ },
+ )
+
ns.AddMethodMapping(ctx.Last,
[]string{"last"},
[][2]string{},
)
+ ns.AddMethodMapping(ctx.Merge,
+ []string{"merge"},
+ [][2]string{
+ {
+ `{{ dict "title" "Hugo Rocks!" | collections.Merge (dict "title" "Default Title" "description" "Yes, Hugo Rocks!") | sort }}`,
+ `[Yes, Hugo Rocks! Hugo Rocks!]`,
+ },
+ {
+ `{{ merge (dict "title" "Default Title" "description" "Yes, Hugo Rocks!") (dict "title" "Hugo Rocks!") | sort }}`,
+ `[Yes, Hugo Rocks! Hugo Rocks!]`,
+ },
+ {
+ `{{ merge (dict "title" "Default Title" "description" "Yes, Hugo Rocks!") (dict "title" "Hugo Rocks!") (dict "extra" "For reals!") | sort }}`,
+ `[Yes, Hugo Rocks! For reals! Hugo Rocks!]`,
+ },
+ },
+ )
+
+ ns.AddMethodMapping(ctx.NewScratch,
+ []string{"newScratch"},
+ [][2]string{
+ {`{{ $scratch := newScratch }}{{ $scratch.Add "b" 2 }}{{ $scratch.Add "b" 2 }}{{ $scratch.Get "b" }}`, `4`},
+ },
+ )
+
ns.AddMethodMapping(ctx.Querify,
[]string{"querify"},
[][2]string{
},
)
- ns.AddMethodMapping(ctx.Shuffle,
- []string{"shuffle"},
+ ns.AddMethodMapping(ctx.Reverse,
+ nil,
[][2]string{},
)
- ns.AddMethodMapping(ctx.Slice,
- []string{"slice"},
+ ns.AddMethodMapping(ctx.Seq,
+ []string{"seq"},
[][2]string{
- {`{{ slice "B" "C" "A" | sort }}`, `[A B C]`},
+ {`{{ seq 3 }}`, `[1 2 3]`},
},
)
- ns.AddMethodMapping(ctx.Sort,
- []string{"sort"},
+ ns.AddMethodMapping(ctx.Shuffle,
+ []string{"shuffle"},
[][2]string{},
)
- ns.AddMethodMapping(ctx.Union,
- []string{"union"},
+ ns.AddMethodMapping(ctx.Slice,
+ []string{"slice"},
[][2]string{
- {`{{ union (slice 1 2 3) (slice 3 4 5) }}`, `[1 2 3 4 5]`},
+ {`{{ slice "B" "C" "A" | sort }}`, `[A B C]`},
},
)
- ns.AddMethodMapping(ctx.Where,
- []string{"where"},
- [][2]string{},
- )
-
- ns.AddMethodMapping(ctx.Append,
- []string{"append"},
- [][2]string{},
- )
-
- ns.AddMethodMapping(ctx.Group,
- []string{"group"},
+ ns.AddMethodMapping(ctx.Sort,
+ []string{"sort"},
[][2]string{},
)
- ns.AddMethodMapping(ctx.Seq,
- []string{"seq"},
+ ns.AddMethodMapping(ctx.SymDiff,
+ []string{"symdiff"},
[][2]string{
- {`{{ seq 3 }}`, `[1 2 3]`},
+ {`{{ slice 1 2 3 | symdiff (slice 3 4) }}`, `[1 2 4]`},
},
)
- ns.AddMethodMapping(ctx.NewScratch,
- []string{"newScratch"},
+ ns.AddMethodMapping(ctx.Union,
+ []string{"union"},
[][2]string{
- {`{{ $scratch := newScratch }}{{ $scratch.Add "b" 2 }}{{ $scratch.Add "b" 2 }}{{ $scratch.Get "b" }}`, `4`},
+ {`{{ union (slice 1 2 3) (slice 3 4 5) }}`, `[1 2 3 4 5]`},
},
)
},
)
- ns.AddMethodMapping(ctx.Merge,
- []string{"merge"},
- [][2]string{
- {
- `{{ dict "title" "Hugo Rocks!" | collections.Merge (dict "title" "Default Title" "description" "Yes, Hugo Rocks!") | sort }}`,
- `[Yes, Hugo Rocks! Hugo Rocks!]`,
- },
- {
- `{{ merge (dict "title" "Default Title" "description" "Yes, Hugo Rocks!") (dict "title" "Hugo Rocks!") | sort }}`,
- `[Yes, Hugo Rocks! Hugo Rocks!]`,
- },
- {
- `{{ merge (dict "title" "Default Title" "description" "Yes, Hugo Rocks!") (dict "title" "Hugo Rocks!") (dict "extra" "For reals!") | sort }}`,
- `[Yes, Hugo Rocks! For reals! Hugo Rocks!]`,
- },
- },
+ ns.AddMethodMapping(ctx.Where,
+ []string{"where"},
+ [][2]string{},
)
return ns
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
+ ns.AddMethodMapping(ctx.Conditional,
+ []string{"cond"},
+ [][2]string{
+ {`{{ cond (eq (add 2 2) 4) "2+2 is 4" "what?" | safeHTML }}`, `2+2 is 4`},
+ },
+ )
+
ns.AddMethodMapping(ctx.Default,
[]string{"default"},
[][2]string{
[][2]string{},
)
- ns.AddMethodMapping(ctx.Ne,
- []string{"ne"},
+ // For internal use only.
+ ns.AddMethodMapping(ctx.LtCollate,
+ nil,
[][2]string{},
)
- ns.AddMethodMapping(ctx.Conditional,
- []string{"cond"},
- [][2]string{
- {`{{ cond (eq (add 2 2) 4) "2+2 is 4" "what?" | safeHTML }}`, `2+2 is 4`},
- },
+ ns.AddMethodMapping(ctx.Ne,
+ []string{"ne"},
+ [][2]string{},
)
return ns
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
+ // Deprecated. Use hash.FNV32a instead.
+ ns.AddMethodMapping(ctx.FNV32a,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.HMAC,
+ []string{"hmac"},
+ [][2]string{
+ {`{{ hmac "sha256" "Secret key" "Hello world, gophers!" }}`, `b6d11b6c53830b9d87036272ca9fe9d19306b8f9d8aa07b15da27d89e6e34f40`},
+ },
+ )
+
ns.AddMethodMapping(ctx.MD5,
[]string{"md5"},
[][2]string{
},
)
- ns.AddMethodMapping(ctx.HMAC,
- []string{"hmac"},
- [][2]string{
- {`{{ hmac "sha256" "Secret key" "Hello world, gophers!" }}`, `b6d11b6c53830b9d87036272ca9fe9d19306b8f9d8aa07b15da27d89e6e34f40`},
- },
- )
-
return ns
}
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
+ ns.AddMethodMapping(ctx.PostCSS,
+ []string{"postCSS"},
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Quoted,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.Sass,
[]string{"toCSS"},
[][2]string{},
)
- ns.AddMethodMapping(ctx.PostCSS,
- []string{"postCSS"},
+ ns.AddMethodMapping(ctx.TailwindCSS,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Unquoted,
+ nil,
[][2]string{},
)
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
+ // Deprecated. Use resources.GetRemote instead.
ns.AddMethodMapping(ctx.GetCSV,
[]string{"getCSV"},
[][2]string{},
)
+ // Deprecated. Use resources.GetRemote instead.
ns.AddMethodMapping(ctx.GetJSON,
[]string{"getJSON"},
[][2]string{},
},
)
+ // For internal use only. Used in tests.
+ ns.AddMethodMapping(ctx.TestDeprecationErr,
+ nil,
+ [][2]string{},
+ )
+
+ // For internal use only. Used in tests.
+ ns.AddMethodMapping(ctx.TestDeprecationInfo,
+ nil,
+ [][2]string{},
+ )
+
+ // For internal use only. Used in tests.
+ ns.AddMethodMapping(ctx.TestDeprecationWarn,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Timer,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.VisualizeSpaces,
+ nil,
+ [][2]string{},
+ )
+
return ns
}
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
+ ns.AddMethodMapping(ctx.Goat,
+ nil,
+ [][2]string{},
+ )
+
return ns
}
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
- ns.AddMethodMapping(ctx.Print,
- []string{"print"},
+ ns.AddMethodMapping(ctx.Errorf,
+ []string{"errorf"},
[][2]string{
- {`{{ print "works!" }}`, `works!`},
+ {`{{ errorf "%s." "failed" }}`, ``},
},
)
- ns.AddMethodMapping(ctx.Println,
- []string{"println"},
+ ns.AddMethodMapping(ctx.Erroridf,
+ []string{"erroridf"},
[][2]string{
- {`{{ println "works!" }}`, "works!\n"},
+ {`{{ erroridf "my-err-id" "%s." "failed" }}`, ``},
+ },
+ )
+
+ // Experimental. Not documented.
+ ns.AddMethodMapping(ctx.Errormf,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Print,
+ []string{"print"},
+ [][2]string{
+ {`{{ print "works!" }}`, `works!`},
},
)
},
)
- ns.AddMethodMapping(ctx.Errorf,
- []string{"errorf"},
+ ns.AddMethodMapping(ctx.Println,
+ []string{"println"},
[][2]string{
- {`{{ errorf "%s." "failed" }}`, ``},
+ {`{{ println "works!" }}`, "works!\n"},
},
)
- ns.AddMethodMapping(ctx.Erroridf,
- []string{"erroridf"},
+ ns.AddMethodMapping(ctx.Warnf,
+ []string{"warnf"},
[][2]string{
- {`{{ erroridf "my-err-id" "%s." "failed" }}`, ``},
+ {`{{ warnf "%s." "warning" }}`, ``},
},
)
},
)
- ns.AddMethodMapping(ctx.Warnf,
- []string{"warnf"},
- [][2]string{
- {`{{ warnf "%s." "warning" }}`, ``},
- },
+ // Experimental. Not documented.
+ ns.AddMethodMapping(ctx.Warnmf,
+ nil,
+ [][2]string{},
)
+
return ns
}
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
- ns.AddMethodMapping(ctx.XxHash,
- []string{"xxhash"},
+ ns.AddMethodMapping(ctx.FNV32a,
+ nil,
[][2]string{
- {`{{ hash.XxHash "The quick brown fox jumps over the lazy dog" }}`, `0b242d361fda71bc`},
+ {`{{ hash.FNV32a "Hugo Rocks!!" }}`, `1515779328`},
},
)
- ns.AddMethodMapping(ctx.FNV32a,
- nil,
+ ns.AddMethodMapping(ctx.XxHash,
+ []string{"xxhash"},
[][2]string{
- {`{{ hash.FNV32a "Hugo Rocks!!" }}`, `1515779328`},
+ {`{{ hash.XxHash "The quick brown fox jumps over the lazy dog" }}`, `0b242d361fda71bc`},
},
)
[][2]string{},
)
+ ns.AddMethodMapping(ctx.Filter,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.QR,
+ nil,
+ [][2]string{},
+ )
+
return ns
}
[][2]string{},
)
+ ns.AddMethodMapping(ctx.Batch,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Build,
+ nil,
+ [][2]string{},
+ )
+
return ns
}
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
- ns.AddMethodMapping(ctx.Translate,
- []string{"i18n", "T"},
- [][2]string{},
- )
-
- ns.AddMethodMapping(ctx.FormatNumber,
- nil,
- [][2]string{
- {`{{ 512.5032 | lang.FormatNumber 2 }}`, `512.50`},
- },
- )
-
- ns.AddMethodMapping(ctx.FormatPercent,
+ ns.AddMethodMapping(ctx.FormatAccounting,
nil,
[][2]string{
- {`{{ 512.5032 | lang.FormatPercent 2 }}`, `512.50%`},
+ {`{{ 512.5032 | lang.FormatAccounting 2 "NOK" }}`, `NOK512.50`},
},
)
},
)
- ns.AddMethodMapping(ctx.FormatAccounting,
+ ns.AddMethodMapping(ctx.FormatNumber,
nil,
[][2]string{
- {`{{ 512.5032 | lang.FormatAccounting 2 "NOK" }}`, `NOK512.50`},
+ {`{{ 512.5032 | lang.FormatNumber 2 }}`, `512.50`},
},
)
},
)
+ ns.AddMethodMapping(ctx.FormatPercent,
+ nil,
+ [][2]string{
+ {`{{ 512.5032 | lang.FormatPercent 2 }}`, `512.50%`},
+ },
+ )
+
+ ns.AddMethodMapping(ctx.Merge,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Translate,
+ []string{"i18n", "T"},
+ [][2]string{},
+ )
+
return ns
}
},
)
+ ns.AddMethodMapping(ctx.Counter,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.Div,
[]string{"div"},
[][2]string{
},
)
+ ns.AddMethodMapping(ctx.Product,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.Rand,
nil,
[][2]string{
},
)
+ ns.AddMethodMapping(ctx.Sum,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.Tan,
nil,
[][2]string{
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
+ ns.AddMethodMapping(ctx.FileExists,
+ []string{"fileExists"},
+ [][2]string{
+ {`{{ fileExists "foo.txt" }}`, `false`},
+ },
+ )
+
ns.AddMethodMapping(ctx.Getenv,
[]string{"getenv"},
[][2]string{},
},
)
- ns.AddMethodMapping(ctx.FileExists,
- []string{"fileExists"},
- [][2]string{
- {`{{ fileExists "foo.txt" }}`, `false`},
- },
+ ns.AddMethodMapping(ctx.Stat,
+ nil,
+ [][2]string{},
)
return ns
},
)
+ ns.AddMethodMapping(ctx.IncludeCached,
+ []string{"partialCached"},
+ [][2]string{},
+ )
+
// TODO(bep) we need the return to be a valid identifiers, but
// should consider another way of adding it.
ns.AddMethodMapping(func() string { return "" },
[][2]string{},
)
- ns.AddMethodMapping(ctx.IncludeCached,
- []string{"partialCached"},
- [][2]string{},
- )
-
return ns
}
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
- ns.AddMethodMapping(ctx.Split,
+ ns.AddMethodMapping(ctx.Base,
nil,
- [][2]string{
- {`{{ "/my/path/filename.txt" | path.Split }}`, `/my/path/|filename.txt`},
- {fmt.Sprintf(`{{ %q | path.Split }}`, filepath.FromSlash("/my/path/filename.txt")), `/my/path/|filename.txt`},
- },
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.BaseName,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Clean,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Dir,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Ext,
+ nil,
+ [][2]string{},
)
testDir := filepath.Join("my", "path")
},
)
+ ns.AddMethodMapping(ctx.Split,
+ nil,
+ [][2]string{
+ {`{{ "/my/path/filename.txt" | path.Split }}`, `/my/path/|filename.txt`},
+ {fmt.Sprintf(`{{ %q | path.Split }}`, filepath.FromSlash("/my/path/filename.txt")), `/my/path/|filename.txt`},
+ },
+ )
+
return ns
}
internal.AddTemplateFuncsNamespace(f)
},
}
- ns.AddMethodMapping(ctx.Get,
+ // Deprecated. Use js.Babel instead.
+ ns.AddMethodMapping(ctx.Babel,
nil,
[][2]string{},
)
- ns.AddMethodMapping(ctx.GetRemote,
+ ns.AddMethodMapping(ctx.ByType,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Concat,
nil,
[][2]string{},
)
- // Add aliases for the most common transformations.
+ ns.AddMethodMapping(ctx.Copy,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.ExecuteAsTemplate,
+ nil,
+ [][2]string{},
+ )
ns.AddMethodMapping(ctx.Fingerprint,
[]string{"fingerprint"},
[][2]string{},
)
+ ns.AddMethodMapping(ctx.FromString,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Get,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Match,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.GetRemote,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Match,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.Minify,
[]string{"minify"},
[][2]string{},
)
+ // Deprecated. Use css.PostCSS instead.
+ ns.AddMethodMapping(ctx.PostCSS,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.PostProcess,
+ nil,
+ [][2]string{},
+ )
+
+ // Deprecated. Use css.Sass instead.
+ ns.AddMethodMapping(ctx.ToCSS,
+ nil,
+ [][2]string{},
+ )
+
return ns
}
},
)
- ns.AddMethodMapping(ctx.CountRunes,
- []string{"countrunes"},
- [][2]string{},
+ ns.AddMethodMapping(ctx.Contains,
+ nil,
+ [][2]string{
+ {`{{ strings.Contains "abc" "b" }}`, `true`},
+ {`{{ strings.Contains "abc" "d" }}`, `false`},
+ },
)
- ns.AddMethodMapping(ctx.RuneCount,
+ ns.AddMethodMapping(ctx.ContainsAny,
nil,
- [][2]string{},
+ [][2]string{
+ {`{{ strings.ContainsAny "abc" "bcd" }}`, `true`},
+ {`{{ strings.ContainsAny "abc" "def" }}`, `false`},
+ },
)
- ns.AddMethodMapping(ctx.CountWords,
- []string{"countwords"},
+ ns.AddMethodMapping(ctx.ContainsNonSpace,
+ nil,
[][2]string{},
)
},
)
- ns.AddMethodMapping(ctx.Contains,
- nil,
- [][2]string{
- {`{{ strings.Contains "abc" "b" }}`, `true`},
- {`{{ strings.Contains "abc" "d" }}`, `false`},
- },
+ ns.AddMethodMapping(ctx.CountRunes,
+ []string{"countrunes"},
+ [][2]string{},
)
- ns.AddMethodMapping(ctx.ContainsAny,
+ ns.AddMethodMapping(ctx.CountWords,
+ []string{"countwords"},
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Diff,
nil,
- [][2]string{
- {`{{ strings.ContainsAny "abc" "bcd" }}`, `true`},
- {`{{ strings.ContainsAny "abc" "def" }}`, `false`},
- },
+ [][2]string{},
)
ns.AddMethodMapping(ctx.FindRE,
},
)
+ ns.AddMethodMapping(ctx.FirstUpper,
+ nil,
+ [][2]string{
+ {`{{ "hugo rocks!" | strings.FirstUpper }}`, `Hugo rocks!`},
+ },
+ )
+
ns.AddMethodMapping(ctx.HasPrefix,
[]string{"hasPrefix"},
[][2]string{
},
)
- ns.AddMethodMapping(ctx.ToLower,
- []string{"lower"},
+ ns.AddMethodMapping(ctx.Repeat,
+ nil,
[][2]string{
- {`{{ lower "BatMan" }}`, `batman`},
+ {`{{ "yo" | strings.Repeat 4 }}`, `yoyoyoyo`},
},
)
},
)
+ ns.AddMethodMapping(ctx.RuneCount,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.SliceString,
[]string{"slicestr"},
[][2]string{
},
)
+ ns.AddMethodMapping(ctx.Title,
+ []string{"title"},
+ [][2]string{
+ {`{{ title "Bat man" }}`, `Bat Man`},
+ {`{{ title "somewhere over the rainbow" }}`, `Somewhere Over the Rainbow`},
+ },
+ )
+
+ ns.AddMethodMapping(ctx.ToLower,
+ []string{"lower"},
+ [][2]string{
+ {`{{ lower "BatMan" }}`, `batman`},
+ },
+ )
+
+ ns.AddMethodMapping(ctx.ToUpper,
+ []string{"upper"},
+ [][2]string{
+ {`{{ upper "BatMan" }}`, `BATMAN`},
+ },
+ )
+
ns.AddMethodMapping(ctx.Trim,
[]string{"trim"},
[][2]string{
},
)
- ns.AddMethodMapping(ctx.TrimSuffix,
+ ns.AddMethodMapping(ctx.TrimSpace,
nil,
- [][2]string{
- {`{{ "aabbaa" | strings.TrimSuffix "a" }}`, `aabba`},
- {`{{ "aabbaa" | strings.TrimSuffix "aa" }}`, `aabb`},
- },
- )
-
- ns.AddMethodMapping(ctx.Title,
- []string{"title"},
- [][2]string{
- {`{{ title "Bat man" }}`, `Bat Man`},
- {`{{ title "somewhere over the rainbow" }}`, `Somewhere Over the Rainbow`},
- },
+ [][2]string{},
)
- ns.AddMethodMapping(ctx.FirstUpper,
+ ns.AddMethodMapping(ctx.TrimSuffix,
nil,
[][2]string{
- {`{{ "hugo rocks!" | strings.FirstUpper }}`, `Hugo rocks!`},
+ {`{{ "aabbaa" | strings.TrimSuffix "a" }}`, `aabba`},
+ {`{{ "aabbaa" | strings.TrimSuffix "aa" }}`, `aabb`},
},
)
},
)
- ns.AddMethodMapping(ctx.Repeat,
- nil,
- [][2]string{
- {`{{ "yo" | strings.Repeat 4 }}`, `yoyoyoyo`},
- },
- )
-
- ns.AddMethodMapping(ctx.ToUpper,
- []string{"upper"},
- [][2]string{
- {`{{ upper "BatMan" }}`, `BATMAN`},
- },
- )
-
return ns
}
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
- ns.AddMethodMapping(ctx.Exists,
+ ns.AddMethodMapping(ctx.Current,
nil,
- [][2]string{
- {`{{ if (templates.Exists "_partials/header.html") }}Yes!{{ end }}`, `Yes!`},
- {`{{ if not (templates.Exists "_partials/doesnotexist.html") }}No!{{ end }}`, `No!`},
- },
+ [][2]string{},
)
ns.AddMethodMapping(ctx.Defer,
[][2]string{},
)
+ // For internal use only.
ns.AddMethodMapping(ctx.DoDefer,
[]string{"doDefer"},
[][2]string{},
)
+ ns.AddMethodMapping(ctx.Exists,
+ nil,
+ [][2]string{
+ {`{{ if (templates.Exists "_partials/header.html") }}Yes!{{ end }}`, `Yes!`},
+ {`{{ if not (templates.Exists "_partials/doesnotexist.html") }}No!{{ end }}`, `No!`},
+ },
+ )
+
return ns
}
},
}
- ns.AddMethodMapping(ctx.Format,
- []string{"dateFormat"},
- [][2]string{
- {`dateFormat: {{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }}`, `dateFormat: Wednesday, Jan 21, 2015`},
- },
- )
-
- ns.AddMethodMapping(ctx.Now,
- []string{"now"},
- [][2]string{},
- )
-
ns.AddMethodMapping(ctx.AsTime,
nil,
[][2]string{
},
)
+ ns.AddMethodMapping(ctx.Format,
+ []string{"dateFormat"},
+ [][2]string{
+ {`dateFormat: {{ dateFormat "Monday, Jan 2, 2006" "2015-01-21" }}`, `dateFormat: Wednesday, Jan 21, 2015`},
+ },
+ )
+
+ ns.AddMethodMapping(ctx.In,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Now,
+ []string{"now"},
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.ParseDuration,
nil,
[][2]string{
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
+ ns.AddMethodMapping(ctx.CanHighlight,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.Emojify,
[]string{"emojify"},
[][2]string{
[][2]string{},
)
+ ns.AddMethodMapping(ctx.HighlightCodeBlock,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.HTMLEscape,
[]string{"htmlEscape"},
[][2]string{
},
)
+ ns.AddMethodMapping(ctx.HTMLToMarkdown,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.HTMLUnescape,
[]string{"htmlUnescape"},
[][2]string{
},
)
+ ns.AddMethodMapping(ctx.PortableText,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.Remarshal,
nil,
[][2]string{
},
)
+ ns.AddMethodMapping(ctx.ToMath,
+ nil,
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.Unmarshal,
[]string{"unmarshal"},
[][2]string{
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
}
+ ns.AddMethodMapping(ctx.AbsLangURL,
+ []string{"absLangURL"},
+ [][2]string{},
+ )
+
ns.AddMethodMapping(ctx.AbsURL,
[]string{"absURL"},
[][2]string{},
)
- ns.AddMethodMapping(ctx.AbsLangURL,
- []string{"absLangURL"},
+ ns.AddMethodMapping(ctx.Anchorize,
+ []string{"anchorize"},
+ [][2]string{
+ {`{{ "This is a title" | anchorize }}`, `this-is-a-title`},
+ },
+ )
+
+ ns.AddMethodMapping(ctx.JoinPath,
+ nil,
+ [][2]string{
+ {`{{ urls.JoinPath "https://example.org" "foo" }}`, `https://example.org/foo`},
+ {`{{ urls.JoinPath (slice "a" "b") }}`, `a/b`},
+ },
+ )
+
+ ns.AddMethodMapping(ctx.Parse,
+ nil,
[][2]string{},
)
- ns.AddMethodMapping(ctx.Ref,
- []string{"ref"},
+
+ ns.AddMethodMapping(ctx.PathEscape,
+ nil,
[][2]string{},
)
- ns.AddMethodMapping(ctx.RelURL,
- []string{"relURL"},
+
+ ns.AddMethodMapping(ctx.PathUnescape,
+ nil,
+ [][2]string{},
+ )
+
+ ns.AddMethodMapping(ctx.Ref,
+ []string{"ref"},
[][2]string{},
)
+
ns.AddMethodMapping(ctx.RelLangURL,
[]string{"relLangURL"},
[][2]string{},
)
+
ns.AddMethodMapping(ctx.RelRef,
[]string{"relref"},
[][2]string{},
)
- ns.AddMethodMapping(ctx.URLize,
- []string{"urlize"},
- [][2]string{},
- )
- ns.AddMethodMapping(ctx.Anchorize,
- []string{"anchorize"},
- [][2]string{
- {`{{ "This is a title" | anchorize }}`, `this-is-a-title`},
- },
+ ns.AddMethodMapping(ctx.RelURL,
+ []string{"relURL"},
+ [][2]string{},
)
- ns.AddMethodMapping(ctx.JoinPath,
- nil,
- [][2]string{
- {`{{ urls.JoinPath "https://example.org" "foo" }}`, `https://example.org/foo`},
- {`{{ urls.JoinPath (slice "a" "b") }}`, `a/b`},
- },
+ ns.AddMethodMapping(ctx.URLize,
+ []string{"urlize"},
+ [][2]string{},
)
return ns