summaryrefslogtreecommitdiffstats
path: root/tpl/tplimpl
AgeCommit message (Collapse)Author
2023-12-29tpl/math: Add math.Rand template functionJoe Mooring
Closes #11833
2023-12-04Pull in the latest code from Go's template packages (#11771)Bjørn Erik Pedersen
Fixes #10707 Fixes #11507
2023-12-04tpl: Allow using page resources on the images page parameter for ↵Razon Yang
`opengraph`, `schema` and `twitter_cards` templates The page images selection order as follows: 1. Page's images parameter, image resources are supported. 2. Page's image resources that naming in *feature*, *cover* or *thumbnail* pattern. 3. If no page images specified, then the first one of site's images will be used as the fallback, supports site resources.
2023-11-27tpl/transform: Add transform.XMLEscape template functionJoe Mooring
Fixes #3268
2023-11-27tpl/tplimpl: Remove superfluous type attr on script elementsJoe Mooring
Closes #6379
2023-11-01tpl/tplimpl: Fix deprecation logic in embedded templatesJoe Mooring
Closes #11658
2023-10-31tpl/tplimpl: Fix deprecation logic in RSS templateJoe Mooring
Closes #11639
2023-10-18hugolib: Deprecate .Site.DisqusShortnameJoe Mooring
Use .Site.Config.Services.Disqus.Shortname instead.
2023-10-18tpl/tplimpl: Fix dropped errorLars Lehtonen
2023-10-17hugolib: Deprecate .Site.GoogleAnalyticsJoe Mooring
Use .Site.Config.Services.GoogleAnalytics.ID instead.
2023-10-17tpl/tplimpl: Deprecate .Site.Author usage in RSS templateJoe Mooring
2023-10-17tpl/tplimpl: Deprecate .Site.Social usage with internal templatesJoe Mooring
2023-10-05all: Format files with gofmtOleksandr Redko
2023-09-23google_analytics_async.html: Add deprecation warningCarl Johnson
2023-06-26tpl/tplimpl: Fix typo in global variable nameOleksandr Redko
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-05-30tpl/tplimpl: Use .Language.LanguageCode in built-in templatesJoe Mooring
2023-05-21tpl/tplimpl: Add img loading attribute to figure shortcode (#10927)InLaw
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-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-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
2022-12-22Revert "tpl/tplimpl: Use https in sitemap templates"Joe Mooring
This reverts commit 3fd0b78498597ceb343b7fda2e9b652f3e957478.
2022-12-14Also consider wrapped errors when checking for file IsNotExist errorsBjørn Erik Pedersen
Fixes #10534
2022-12-11tpl/tplimpl: Use https in sitemap templatesJoe Mooring
Closes #10515
2022-12-06tpl/embedded: Make Open Graph's series optionalRazon Yang
2022-12-04tpl/tplimpl: Allow alternate comment syntaxJoe Mooring
Allow alternate comment syntax before block definitions: {{/* foo */}} {{- /* foo */}} {{- /* foo */ -}} Fixes #10495
2022-07-13Cache when not found in LookupLayoutBjørn Erik Pedersen
Very visible when using the pprof mutex profiler. ```bash name old time/op new time/op delta Baseline-10 58.4ms ± 1% 51.6ms ± 0% -11.56% (p=0.029 n=4+4) name old alloc/op new alloc/op delta Baseline-10 64.3MB ± 0% 64.2MB ± 0% ~ (p=0.114 n=4+4) name old allocs/op new allocs/op delta Baseline-10 649k ± 0% 649k ± 0% ~ (p=0.229 n=4+4) ```
2022-05-31Fix indentation in highlight shortcodeBjørn Erik Pedersen
This commit adds a new `.InnerDeindent` method to the shortcode context, which is `.Inner` with any indendation removed. This is then used in the built-in `highlight` shortcode to prevent the extra whitespace getting hightlighted. Fixes #4717
2022-05-15Improve SASS errorsBjørn Erik Pedersen
Fixes #9897
2022-05-15postcss: Fix import error handlingBjørn Erik Pedersen
Note that we will now fail if `inlineImports` is enabled and we cannot resolve an import. You can work around this by either: * Use url imports or imports with media queries. * Set `skipInlineImportsNotFound=true` in the options Also get the argument order in the different NewFileError* funcs in line. Fixes #9895
2022-05-14errors: Misc improvementsBjørn Erik Pedersen
* Redo the server error template * Always add the content file context if relevant * Remove some now superflous error string matching * Move the server error template to _server/error.html * Add file context (with position) to codeblock render blocks * Improve JS build errors Fixes #9892 Fixes #9891 Fixes #9893
2022-05-09Revise the use of htime.Since/htime.NowBjørn Erik Pedersen
We cannot (also, it doesn't add any value) use that when the `clock` is set, * To measure time (before that global is set) * To compare file timestamps re cache eviction Fixes #9868
2022-05-08Add `clock` cli flagsatotake
Close #8787
2022-05-06Improve error messages, esp. when the server is runningBjørn Erik Pedersen
* Add file context to minifier errors when publishing * Misc fixes (see issues) * Allow custom server error template in layouts/server/error.html To get to this, this commit also cleans up and simplifies the code surrounding errors and files. This also removes the usage of `github.com/pkg/errors`, mostly because of https://github.com/pkg/errors/issues/223 -- but also because most of this is now built-in to Go. Fixes #9852 Fixes #9857 Fixes #9863
2022-03-17all: gofmt -w -r 'interface{} -> any' .Bjørn Erik Pedersen
Updates #9687
2022-03-16tpl: Pull in Go 1.18 patch that fixes the "no space in {{ continue }} and {{ ↵Bjørn Erik Pedersen
break }}" bug
2022-03-16tpl: Adjustments and an integration test for Go 1.18Bjørn Erik Pedersen
Updates #9677
2022-03-09Add lang attribute to internal alias templateJoe Mooring
Closes #9586
2022-03-08Cache reflect.MethodByNameBjørn Erik Pedersen
The isolated benchmark for the function is obviously much faster: ```bash name old time/op new time/op delta GetMethodByName-10 1.21µs ± 7% 0.23µs ± 5% -81.42% (p=0.029 n=4+4) name old alloc/op new alloc/op delta GetMethodByName-10 680B ± 0% 0B -100.00% (p=0.029 n=4+4) name old allocs/op new allocs/op delta GetMethodByName-10 20.0 ± 0% 0.0 -100.00% (p=0.029 n=4+4) ``` But more pleasing is the overall performance looking at the site benchmarks: ```bash name old time/op new time/op delta SiteNew/Regular_Bundle_with_image-10 6.25ms ± 2% 6.10ms ± 2% ~ (p=0.057 n=4+4) SiteNew/Regular_Bundle_with_JSON_file-10 6.30ms ± 2% 5.66ms ±11% ~ (p=0.057 n=4+4) SiteNew/Regular_Tags_and_categories-10 22.2ms ± 2% 17.4ms ± 1% -21.88% (p=0.029 n=4+4) SiteNew/Regular_Canonify_URLs-10 108ms ± 0% 107ms ± 0% -1.20% (p=0.029 n=4+4) SiteNew/Regular_Deep_content_tree-10 36.1ms ± 1% 33.8ms ± 1% -6.44% (p=0.029 n=4+4) SiteNew/Regular_TOML_front_matter-10 24.9ms ± 1% 22.6ms ± 1% -9.30% (p=0.029 n=4+4) SiteNew/Regular_Many_HTML_templates-10 17.9ms ± 1% 16.7ms ± 1% -6.43% (p=0.029 n=4+4) SiteNew/Regular_Page_collections-10 23.3ms ± 1% 22.0ms ± 0% -5.58% (p=0.029 n=4+4) SiteNew/Regular_List_terms-10 8.00ms ± 1% 7.63ms ± 0% -4.62% (p=0.029 n=4+4) name old alloc/op new alloc/op delta SiteNew/Regular_Bundle_with_image-10 2.10MB ± 0% 2.07MB ± 0% -1.46% (p=0.029 n=4+4) SiteNew/Regular_Bundle_with_JSON_file-10 1.88MB ± 0% 1.85MB ± 0% -1.76% (p=0.029 n=4+4) SiteNew/Regular_Tags_and_categories-10 13.5MB ± 0% 11.6MB ± 0% -13.99% (p=0.029 n=4+4) SiteNew/Regular_Canonify_URLs-10 96.1MB ± 0% 95.8MB ± 0% -0.40% (p=0.029 n=4+4) SiteNew/Regular_Deep_content_tree-10 28.4MB ± 0% 27.3MB ± 0% -3.83% (p=0.029 n=4+4) SiteNew/Regular_TOML_front_matter-10 16.9MB ± 0% 15.1MB ± 0% -10.58% (p=0.029 n=4+4) SiteNew/Regular_Many_HTML_templates-10 8.98MB ± 0% 8.44MB ± 0% -6.04% (p=0.029 n=4+4) SiteNew/Regular_Page_collections-10 17.1MB ± 0% 16.5MB ± 0% -3.91% (p=0.029 n=4+4) SiteNew/Regular_List_terms-10 3.92MB ± 0% 3.72MB ± 0% -5.03% (p=0.029 n=4+4) name old allocs/op new allocs/op delta SiteNew/Regular_Bundle_with_image-10 25.8k ± 0% 24.9k ± 0% -3.49% (p=0.029 n=4+4) SiteNew/Regular_Bundle_with_JSON_file-10 25.8k ± 0% 24.9k ± 0% -3.49% (p=0.029 n=4+4) SiteNew/Regular_Tags_and_categories-10 288k ± 0% 233k ± 0% -18.90% (p=0.029 n=4+4) SiteNew/Regular_Canonify_URLs-10 375k ± 0% 364k ± 0% -2.80% (p=0.029 n=4+4) SiteNew/Regular_Deep_content_tree-10 314k ± 0% 283k ± 0% -9.77% (p=0.029 n=4+4) SiteNew/Regular_TOML_front_matter-10 302k ± 0% 252k ± 0% -16.55% (p=0.029 n=4+4) SiteNew/Regular_Many_HTML_templates-10 133k ± 0% 117k ± 0% -11.81% (p=0.029 n=4+4) SiteNew/Regular_Page_collections-10 202k ± 0% 183k ± 0% -9.55% (p=0.029 n=4+4) SiteNew/Regular_List_terms-10 55.6k ± 0% 49.8k ± 0% -10.40% (p=0.029 n=4+4) ``` Thanks to @quasilyte for the suggestion. Fixes 9386
2022-02-27tpl/diagrams: Rename Body to InnerBjørn Erik Pedersen
This relates to #9577 – there's no concept a body element in SVG, so we might as well use an exsisting "Hugo term".
2022-02-27CodeblockContext method renamesBjørn Erik Pedersen
Fixes #9577
2022-02-25Move the Goat template to the correct placeBjørn Erik Pedersen
Updates #7765
2022-02-24Add Markdown diagrams and render hooks for code blocksBjørn Erik Pedersen
You can now create custom hook templates for code blocks, either one for all (`render-codeblock.html`) or for a given code language (e.g. `render-codeblock-go.html`). We also used this new hook to add support for diagrams in Hugo: * Goat (Go ASCII Tool) is built-in and enabled by default; just create a fenced code block with the language `goat` and start draw your Ascii diagrams. * Another popular alternative for diagrams in Markdown, Mermaid (supported by GitHub), can also be implemented with a simple template. See the Hugo documentation for more information. Updates #7765 Closes #9538 Fixes #9553 Fixes #8520 Fixes #6702 Fixes #9558
2022-02-23Change `disqus_config` to `window.disqus_config`Akimo
2022-02-17tpl/partials: Fix recently introduced deadlock in partials cacheBjørn Erik Pedersen
The change in lock logic for `partialCached` in 0927cf739fee9646c7fb917965799d9acf080922 was naive as it didn't consider cached partials calling other cached partials. This changeset may look on the large side for this particular issue, but it pulls in part of a working branch, introducing `context.Context` in the template execution. Note that the context is only partially implemented in this PR, but the upcoming use cases will, as one example, include having access to the top "dot" (e.g. `Page`) all the way down into partials and shortcodes etc. The earlier benchmarks rerun against master: ```bash name old time/op new time/op delta IncludeCached-10 13.6ms ± 2% 13.8ms ± 1% ~ (p=0.343 n=4+4) name old alloc/op new alloc/op delta IncludeCached-10 5.30MB ± 0% 5.35MB ± 0% +0.96% (p=0.029 n=4+4) name old allocs/op new allocs/op delta IncludeCached-10 74.7k ± 0% 75.3k ± 0% +0.77% (p=0.029 n=4+4) ``` Fixes #9519
2022-02-15tpl: Remove TODO commentBjørn Erik Pedersen
2022-02-15Add --printUnusedTemplatesBjørn Erik Pedersen
Fixes #9502