summaryrefslogtreecommitdiffstats
path: root/tpl
AgeCommit message (Collapse)Author
2019-09-29Support typed bool, int and float in shortcode paramsBjørn Erik Pedersen
This means that you now can do: {{< vidur 9KvBeKu false true 32 3.14 >}} And the boolean and numeric values will be converted to `bool`, `int` and `float64`. If you want these to be strings, they must be quoted: {{< vidur 9KvBeKu "false" "true" "32" "3.14" >}} Fixes #6371
2019-09-21tpl: Add `rel="noopener"` for external linksXhmikosR
This could be a security and performance issue. See https://developers.google.com/web/tools/lighthouse/audits/noopener
2019-09-21tpl: Remove unneeded spaceXhmikosR
2019-09-05tpl: Remove eq argument limitationVazrupe (HyeonGyu Lee)
Fixes #6237
2019-09-04Allow slices in the image Filter funcs, not just varargsBjørn Erik Pedersen
[ci skip] See #6255
2019-08-30tpl: Migrate last shortcodes (YouTube and Vimeo) to HTTPS embedsJake Jarvis
2019-08-28Add a set of image filtersBjørn Erik Pedersen
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes #6255
2019-08-26Image resource refactorBjørn Erik Pedersen
This commit pulls most of the image related logic into its own package, to make it easier to reason about and extend. This is also a rewrite of the transformation logic used in Hugo Pipes, mostly to allow constructs like the one below: {{ ($myimg | fingerprint ).Width }} Fixes #5903 Fixes #6234 Fixes #6266
2019-08-17tpl: Use RegularPages for RSS templateBjørn Erik Pedersen
This is in line with how it was in Hugo 0.56. See #6238
2019-08-17tpl: Avoid "home page warning" in RSS templateBjørn Erik Pedersen
See #6238
2019-08-13Add resources.Match and resources.GetMatchBjørn Erik Pedersen
Fix #6190
2019-08-12tests: Convert from testify to quicktestBjørn Erik Pedersen
2019-08-10Avoid unnecessary conversionsChristian Muehlhaeuser
No need to convert these types.
2019-08-10Fixed ineffectual assignmentsChristian Muehlhaeuser
Dropped/fixed ineffectual assignments after static code analysis.
2019-08-10Simplify codeChristian Muehlhaeuser
- Use bytes.Equal instead of bytes.Compare - Omit range's value where it's unused
2019-08-08Simplify page tree logicBjørn Erik Pedersen
This is preparation for #6041. For historic reasons, the code for bulding the section tree and the taxonomies were very much separate. This works, but makes it hard to extend, maintain, and possibly not so fast as it could be. This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues: This commit also switches the radix tree dependency to a mutable implementation: github.com/armon/go-radix. Fixes #6154 Fixes #6153 Fixes #6152
2019-08-01tpl: Regenerate templatesBjørn Erik Pedersen
2019-08-01tpl: Always load GitHub Gists over HTTPSChristian Oliff
2019-08-01Fix assorted typosXhmikosR
2019-08-01Merge pull request #6149 from bep/sort-caseinsensitiveBjørn Erik Pedersen
Implement lexicographically string sorting
2019-07-25Block symlink dir traversal for /staticBjørn Erik Pedersen
This is in line with how it behaved before, but it was lifted a little for the project mount for Hugo Modules, but that could create hard-to-detect loops.
2019-07-24Add Hugo ModulesBjørn Erik Pedersen
This commit implements Hugo Modules. This is a broad subject, but some keywords include: * A new `module` configuration section where you can import almost anything. You can configure both your own file mounts nd the file mounts of the modules you import. This is the new recommended way of configuring what you earlier put in `configDir`, `staticDir` etc. And it also allows you to mount folders in non-Hugo-projects, e.g. the `SCSS` folder in the Bootstrap GitHub project. * A module consists of a set of mounts to the standard 7 component types in Hugo: `static`, `content`, `layouts`, `data`, `assets`, `i18n`, and `archetypes`. Yes, Theme Components can now include content, which should be very useful, especially in bigger multilingual projects. * Modules not in your local file cache will be downloaded automatically and even "hot replaced" while the server is running. * Hugo Modules supports and encourages semver versioned modules, and uses the minimal version selection algorithm to resolve versions. * A new set of CLI commands are provided to manage all of this: `hugo mod init`, `hugo mod get`, `hugo mod graph`, `hugo mod tidy`, and `hugo mod vendor`. All of the above is backed by Go Modules. Fixes #5973 Fixes #5996 Fixes #6010 Fixes #5911 Fixes #5940 Fixes #6074 Fixes #6082 Fixes #6092
2019-07-15tpl/collections: Add Merge functionBjørn Erik Pedersen
Merges two maps recursively and returns a new one. Merge is case-insensitive. Fixes #5992
2019-06-26tpl/tplimpl: Regenerate templatesBjørn Erik Pedersen
2019-06-26Pagination - do not render href if no next itemMark Mandel
When using a html link checker with Hugo, this template consistently causes errors, as it renders `href=""` attributes when next/previous is disabled. This change makes it so that the `href` attribute is not rendered at all if `HasNext` is false - which is better semantically, and makes link checking far easier.
2019-06-10tpl/collections: Fix slice type handling in sortBjørn Erik Pedersen
The `sort` template func was producing a `[]page.Page` which did not work in `.Paginate`. Fixes #6023
2019-06-09tpl/collections: Unwrap any interface value in sort and whereBjørn Erik Pedersen
Hugo `0.55.0` introduced some new interface types for `Page` etc. This worked great in general, but there were cases where this would fail in `where` and `sort`. One such example would be sorting by `MenuItem.Page.Date` where `Page` on `MenuItem` was a small subset of the bigger `page.Page` interface. This commit fixes that by unwrapping such interface values. Fixes #5989
2019-05-30tpl/collections: Convert numeric values to float64 and compare themAnton Harniakou
Fixes #5685
2019-05-26Remove references to Google+Bruno Amaral
According to google, this is no longer supported and structured data should be used instead: https://support.google.com/webmasters/answer/6083347?hl=en
2019-05-17tpl: Fix internal templates usage of safeHTMLAttrRodolfo Carvalho
The `safeHTMLAttr` function operates on a full attribute definition, not just within the attribute value. Docs: https://gohugo.io/functions/safehtmlattr/ For `opengraph.html`, run the whole `content` HTML attribute through `safeHTMLAttr`. That will preserve `+` signs in formatted dates. For `vimeo_simple.html`, `safeHTMLAttr` was in the context of an attribute value, thus having no effect. In this case we could replace it with `safeURL`, but since the code is coming from an API it is safer to just let Go's template engine sanitize the value as it already does with `provider_url`. Fixes #5236 (no need to change Go upstream) Related to #5246
2019-05-04i18n: Move the package below /langsBjørn Erik Pedersen
To get fewer top level packages.
2019-04-29tpl/compare: Fix nil compare in eq/ne for interface valuesBjørn Erik Pedersen
Fixes #5905
2019-04-27tpl: Fix hugo package name and add godocsCameron Moore
2019-04-27tpl: Provide more detailed errors in WhereCameron Moore
2019-04-24hugolib: Avoid recloning of shortcode templatesBjørn Erik Pedersen
```bash benchmark old ns/op new ns/op delta BenchmarkSiteNew/Bundle_with_image-4 14572242 14382188 -1.30% BenchmarkSiteNew/Bundle_with_JSON_file-4 13683922 13738196 +0.40% BenchmarkSiteNew/Multiple_languages-4 41912231 25192494 -39.89% benchmark old allocs new allocs delta BenchmarkSiteNew/Bundle_with_image-4 57496 57493 -0.01% BenchmarkSiteNew/Bundle_with_JSON_file-4 57492 57501 +0.02% BenchmarkSiteNew/Multiple_languages-4 242422 118809 -50.99% benchmark old bytes new bytes delta BenchmarkSiteNew/Bundle_with_image-4 3845077 3844065 -0.03% BenchmarkSiteNew/Bundle_with_JSON_file-4 3627442 3627798 +0.01% BenchmarkSiteNew/Multiple_languages-4 13963502 7543885 -45.97% ``` Fixes #5890
2019-04-19tpl/collections: Return error on invalid input in inBjørn Erik Pedersen
See #5875
2019-04-18tpl/collections: Make Pages etc. work with the in funcBjørn Erik Pedersen
Fixes #5875
2019-04-18tpl/collections: Make Pages etc. work in uniqBjørn Erik Pedersen
Fixes #5852
2019-04-16tpl/tplimpl: Handle late transformation of templatesBjørn Erik Pedersen
Fixes #5865
2019-04-15hugolib: Fix shortcode namespace issueBjørn Erik Pedersen
Fixes #5863
2019-04-09tpl/tplimpl: Replace deprecated .GetParam usageBjørn Erik Pedersen
Fixes #5834
2019-04-08Misc paginator adjustmentsBjørn Erik Pedersen
* Rewind paginator for server mode * Add some more related tests. * Replace the clumsy scratch constructs in internal paginator template with variables See #5825
2019-04-05hugolib: Consider summary in front matter for .SummaryJim McDonald
Add the ability to have a `summary` page variable that overrides the auto-generated summary. Logic for obtaining summary becomes: * if summary divider is present in content, use the text above it * if summary variables is present in page metadata, use that * auto-generate summary from first _x_ words of the content Fixes #5800
2019-04-02tpl: Allow the partial template func to return any typeBjørn Erik Pedersen
This commit adds support for return values in partials. This means that you can now do this and similar: {{ $v := add . 42 }} {{ return $v }} Partials without a `return` statement will be rendered as before. This works for both `partial` and `partialCached`. Fixes #5783
2019-03-24all: Apply staticcheck recommendationsBjørn Erik Pedersen
2019-03-23Run gofmt -sBjørn Erik Pedersen
2019-03-23Make Page an interfaceBjørn Erik Pedersen
The main motivation of this commit is to add a `page.Page` interface to replace the very file-oriented `hugolib.Page` struct. This is all a preparation step for issue #5074, "pages from other data sources". But this also fixes a set of annoying limitations, especially related to custom output formats, and shortcodes. Most notable changes: * The inner content of shortcodes using the `{{%` as the outer-most delimiter will now be sent to the content renderer, e.g. Blackfriday. This means that any markdown will partake in the global ToC and footnote context etc. * The Custom Output formats are now "fully virtualized". This removes many of the current limitations. * The taxonomy list type now has a reference to the `Page` object. This improves the taxonomy template `.Title` situation and make common template constructs much simpler. See #5074 Fixes #5763 Fixes #5758 Fixes #5090 Fixes #5204 Fixes #4695 Fixes #5607 Fixes #5707 Fixes #5719 Fixes #3113 Fixes #5706 Fixes #5767 Fixes #5723 Fixes #5769 Fixes #5770 Fixes #5771 Fixes #5759 Fixes #5776 Fixes #5777 Fixes #5778
2019-03-16tpl/tplimpl: Fix mutex unlockBjørn Erik Pedersen
2019-03-06tpl/tplimpl: Fix template truth logicBjørn Erik Pedersen
Before this commit, due to a bug in Go's `text/template` package, this would print different output for typed nil interface values: ``` {{ if .AuthenticatedUser }}User is authenticated!{{ else }}{{ end }} {{ if not .AuthenticatedUser }}{{ else }}}User is authenticated!{{ end }} ``` This commit works around this by wrapping every `if` and `with` with a custom `getif` template func with truth logic that matches `not`, `and` and `or`. Those 3 template funcs from Go's stdlib are now pulled into Hugo's source tree and adjusted to support custom zero values, e.g. types that implement `IsZero`. This means that you can now do: ``` {{ with .Date }}{{ . }}{{ end }} ``` And it would work as expected. Fixes #5738
2019-02-06Support nested keys/fields with missing values with the `where` functionAnton Harniakou
Before this commit `where` would produce an error and bail building the site. Now, `where` simply skips an element of a collection and does not add it to the final result. Closes #5637 Closes #5416