summaryrefslogtreecommitdiffstats
path: root/tpl
AgeCommit message (Collapse)Author
2023-08-03Add Page.RenderShortcodesBjørn Erik Pedersen
A layouts/shortcodes/include.html shortcode may look like this: ```html {{ $p := site.GetPage (.Get 0) }} {{ $p.RenderShortcodes }} ``` Fixes #7297
2023-07-28tpl/collections: Add BenchmarkWhereOpsBjørn Erik Pedersen
``` BenchmarkWhereOps/eq-10 8702 120410 ns/op 52280 B/op 2515 allocs/op BenchmarkWhereOps/ne-10 9829 120759 ns/op 52280 B/op 2515 allocs/op BenchmarkWhereOps/like-10 6754 176377 ns/op 52917 B/op 2515 allocs/op ```
2023-07-28tpl/collections: Add like operator to where functionJoe Mooring
Closes #11279
2023-07-28tpl/collections: Fix description of apply functionJoe Mooring
The collections.Apply template function cannot be used with maps.
2023-07-27Add a common regexp cacheBjørn Erik Pedersen
``` BenchmarkGetOrCompileRegexp-10 73959368 13.71 ns/op 0 B/op 0 allocs/op BenchmarkCompileRegexp-10 3143529 380.1 ns/op 872 B/op 10 allocs/op ```
2023-07-11tpl/collections: Fix WordCount (etc.) regression in Where, Sort, DelimitBjørn Erik Pedersen
Fixes #11234
2023-07-08Make imageConfig work with modulesBjørn Erik Pedersen
Fixes #11205
2023-06-28Fix output formats and media type per language config regressionBjørn Erik Pedersen
Fixes #11159
2023-06-28common/collections: Fix append regression to allow appending nilkhayyam
Closes #11180
2023-06-26tpl/tplimpl: Fix typo in global variable nameOleksandr Redko
2023-06-18Replace the old log setup, with structured logging etc.Bjørn Erik Pedersen
Fixes #11124
2023-06-15Fix upstream Go templates bug with reversed key/value assignmentBjørn Erik Pedersen
The template packages are based on go1.20.5 with the patch in befec5ddbbfbd81ec84e74e15a38044d67f8785b added. This also includes a security fix that now disallows Go template actions in JS literals (inside backticks). This will throw an error saying "... appears in a JS template literal". If you're really sure this isn't a security risk in your case, you can revert to the old behaviour: ```toml [security] [security.gotemplates] allowActionJSTmpl = true ``` See https://github.com/golang/go/issues/59234 Fixes #11112
2023-06-14tpl/collections: Fix append when appending a slice to a slice of slicesBjørn Erik Pedersen
Fixes #11093
2023-06-13tpl/math: Allow variadic math functions to take slice args, add ↵Bjørn Erik Pedersen
math.Product, math.Sum * Update math.Min and math.Max to allow 1 or more args, either scalar or slice, or combination of the two * Add math.Sum (allow 1 or more args, either scalar or slice, or combination of the two) * Add math.Product (allow 1 or more args, either scalar or slice, or combination of the two) Fixes #11030
2023-06-01markup: Fix typo in function and struct namesOleksandr Redko
2023-06-01all: Replace deprecated ioutil with io and osOleksandr Redko
2023-05-30tpl/tplimpl: Use .Language.LanguageCode in built-in templatesJoe Mooring
2023-05-29Fix potential deadlock in ByParamBjørn Erik Pedersen
Fixes #11039
2023-05-22docs: Regen docshelperBjørn Erik Pedersen
2023-05-21tpl/tplimpl: Add img loading attribute to figure shortcode (#10927)InLaw
2023-05-20Add hugo.WorkingDirBjørn Erik Pedersen
Fixes #10969
2023-05-20tpl/urls: Return empty string when JoinPath has zero argsJoe Mooring
2023-05-19tpl/urls: Fix build broken by a mergeBjørn Erik Pedersen
2023-05-19tpl/urls: Add JoinPath template functionJoe Mooring
See https://pkg.go.dev/net/url#JoinPath Closes #9694
2023-05-18all: Fix comments for exported functions and packagesOleksandr Redko
2023-05-17tpl/lang: document delimiter option for FormatNumberCustomJoe Mooring
Closes gohugoio/hugoDocs#1760
2023-05-16tpl: Add math.AbsOleksandr Redko
Fixes #10941.
2023-05-16Create a struct with all of Hugo's config optionsBjørn Erik Pedersen
Primary motivation is documentation, but it will also hopefully simplify the code. Also, * Lower case the default output format names; this is in line with the custom ones (map keys) and how it's treated all the places. This avoids doing `stringds.EqualFold` everywhere. Closes #10896 Closes #10620
2023-04-27tpl/strings: Clarify findRESubmatch descriptionJoe Mooring
2023-04-20tpl/debug: Add VisualizeSpacesBjørn Erik Pedersen
2023-03-20resources.functions: improve validationAndreas Deininger
2023-03-14tpl/math: Return error if less than 2 input numberssepts
Fixes #10827
2023-03-12Run gofmt -s on source filesAndreas Deininger
2023-03-11tpl/math: Allow multi numbers in add, sub, mul, div, min and maxsepts
2023-03-08tpl: Add hasSuffix aliasJonathan Fisher
strings.HasPrefix already has an alias of hasPrefix but strings.HasSuffix has no such alias. This PR adds a hasSuffix alias to the tpl function with corresponding function documentation. It also adds a Minor update to the hasPrefix function documentation re: keywords and relatedfuncs. Completes https://github.com/gohugoio/hugo/issues/10474
2023-03-05Allow page.TableOfContents on self in shortcodeBjørn Erik Pedersen
Fixes #10791
2023-03-04tpl/partial: Consolidate GoDocBjørn Erik Pedersen
2023-03-04Fix "context canceled" with partialBjørn Erik Pedersen
Make sure the context used for timeouts isn't created based on the incoming context, as we have cases where this can cancel the context prematurely. Fixes #10789
2023-03-04Page context handling in i18nBjørn Erik Pedersen
This is a workaround. We need to improve on this, but not today. Fixes #10782
2023-03-02Correct typos in Go commentsOleksandr Redko
2023-03-02Fix "page" not definedBjørn Erik Pedersen
Fixes #10774
2023-03-01tpl/tplimpl: Remove the Google News internal templateJoe Mooring
This was deprecated, with a warning message, on 21 Nov 2021. Reference #9190
2023-03-01strings: fix Truncate behavior for formatted htmlKhayyam Saleem
Before this fix, strings.Truncate would erroneously re-include attributes from the opening tag in the closing tag when closing formatted html, due to a bug in how tagnames were extracted from the regex capture group for html tags used in `truncate.go`. This change ensures that only the tagname is retained and all attributes are discarded when storing the tags for closing them later. Fixes #10399
2023-03-01tpl/strings: Adjust benchmarkBjørn Erik Pedersen
2023-03-01tpl/strings: Add BenchmarkTruncateBjørn Erik Pedersen
2023-03-01Replace deprecated ioutil with io and osOleksandr Redko
https://pkg.go.dev/io/ioutil is deprecated since Go 1.16.
2023-02-25Add a page template funcBjørn Erik Pedersen
Fixes #9339
2023-02-22tocss: Simplify the hugo:vars type handlingBjørn Erik Pedersen
Instead of maintaing a list of all CSS units and functions this commit: * Uses 3 regexps to detect typed CSS values (e.g. `24px`) + properly handle numeric Go types. * These regexps may have some false positives -- e.g. strings that needs to be quoted. * For that rare case, you can mark the string with e.g. `"32xxx" | css.Quoted` * For the opposite case: `"32" | css.Unquoted` Updates #10632
2023-02-22tpl/internal: Sync Go template src to Go 1.20Bjørn Erik Pedersen
Updates #10691
2023-02-21Add page fragments support to RelatedBjørn Erik Pedersen
The main topic of this commit is that you can now index fragments (content heading identifiers) when calling `.Related`. You can do this by: * Configure one or more indices with type `fragments` * The name of those index configurations maps to an (optional) front matter slice with fragment references. This allows you to link page<->fragment and page<->page. * This also will index all the fragments (heading identifiers) of the pages. It's also possible to use type `fragments` indices in shortcode, e.g.: ``` {{ $related := site.RegularPages.Related .Page }} ``` But, and this is important, you need to include the shortcode using the `{{<` delimiter. Not doing so will create infinite loops and timeouts. This commit also: * Adds two new methods to Page: Fragments (can also be used to build ToC) and HeadingsFiltered (this is only used in Related Content with index type `fragments` and `enableFilter` set to true. * Consolidates all `.Related*` methods into one, which takes either a `Page` or an options map as its only argument. * Add `context.Context` to all of the content related Page API. Turns out it wasn't strictly needed for this particular feature, but it will soon become usefil, e.g. in #9339. Closes #10711 Updates #9339 Updates #10725