summaryrefslogtreecommitdiffstats
path: root/tpl
AgeCommit message (Collapse)Author
2018-04-02Add support for a content dir set per languageBjørn Erik Pedersen
A sample config: ```toml defaultContentLanguage = "en" defaultContentLanguageInSubdir = true [Languages] [Languages.en] weight = 10 title = "In English" languageName = "English" contentDir = "content/english" [Languages.nn] weight = 20 title = "På Norsk" languageName = "Norsk" contentDir = "content/norwegian" ``` The value of `contentDir` can be any valid path, even absolute path references. The only restriction is that the content dirs cannot overlap. The content files will be assigned a language by 1. The placement: `content/norwegian/post/my-post.md` will be read as Norwegian content. 2. The filename: `content/english/post/my-post.nn.md` will be read as Norwegian even if it lives in the English content folder. The content directories will be merged into a big virtual filesystem with one simple rule: The most specific language file will win. This means that if both `content/norwegian/post/my-post.md` and `content/english/post/my-post.nn.md` exists, they will be considered duplicates and the version inside `content/norwegian` will win. Note that translations will be automatically assigned by Hugo by the content file's relative placement, so `content/norwegian/post/my-post.md` will be a translation of `content/english/post/my-post.md`. If this does not work for you, you can connect the translations together by setting a `translationKey` in the content files' front matter. Fixes #4523 Fixes #4552 Fixes #4553
2018-03-20tpl/transform: Add a comments test for RemarshalBjørn Erik Pedersen
See #4521
2018-03-16Add a way to merge pages by languageBjørn Erik Pedersen
As an example: ```html {{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }} ``` Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English. Fixes #4463
2018-02-22Properly handle -DEV suffix when comparing Hugo versionsBjørn Erik Pedersen
See #4443
2018-02-22Make ge, le etc. work with the Hugo Version numberBjørn Erik Pedersen
This means that you can do something ala: ```html {{ if ge .Hugo.Version "0.36" }}Reasonable new Hugo version!{{ end }} ``` The intented use is feature toggling, but please note that it will take some time and Hugo versions until this can be trusted. It does not work in older Hugo versions. Fixes #4443
2018-02-10tpl/transform: Add template func for TOML/JSON/YAML docs examples conversionBjørn Erik Pedersen
Usage: ```html {{ "title = \"Hello World\"" | transform.Remarshal "json" | safeHTML }} ``` Fixes #4389
2018-02-09Add "target" and "rel" parameters to figure shortcodeKaushal Modi
Also: - Remove unnecessary space from `figure` tag if no class is specified. - Update related tests. - Add test cases for the changes made to the figure shortcode. - Document the newly added target and rel parameters - Add more detail to the documentation of all figure shortcode parameters.
2018-02-09Use more canonical "twitter:image" property, not "twitter:image:src"Kaushal Modi
This change is made in the "twitter_cards" internal template. References: - https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary-card-with-large-image - https://twittercommunity.com/t/twitter-image-src-or-twitter-image/16085/7
2018-02-05tpl: Ensure site templates can override theme templatesCameron Moore
The tplimpl package was misusing the TemplateLookupDescriptor.WorkingDir field from the output package. By incorrectly setting it to the theme directory instead of the site root, the user is unable to override theme templates in some situations. Fixes #3505
2018-01-29tpl: Update Twitter card to also consider images in .ResourcesBjørn Erik Pedersen
The new lookup order: 1) Page.Params.images if set 2) Image resources: images with name "feature" (priority), "cover", "thumbnail" 3) Site.Params.images if set Fixes #4349
2018-01-27tpl/collections: Seed random on init onlyliguoqinjim
2017-12-29tpl/transform: Do not unescape input to highlightBjørn Erik Pedersen
Fixes #4179
2017-12-17tpl/strings: Fix broken testBjørn Erik Pedersen
2017-12-16Make chomp return the type it receivesVictor Kropp
fixes #2187
2017-12-16Reuse the BlackFriday instance when possibleBjørn Erik Pedersen
This is in heavy use in rendering, so this makes a difference: ```bash benchmark old ns/op new ns/op delta BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4 124551144 107743429 -13.49% benchmark old allocs new allocs delta BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4 528684 435118 -17.70% benchmark old bytes new bytes delta BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4 53306848 45147832 -15.31% ```
2017-12-01Fix context of opengraph video rangeChristian Nolte
Fixes #4136
2017-11-28vendor: Fix Humanize for multi-byte runesBjørn Erik Pedersen
Fixes #4133
2017-11-25tpl/images: Close image fileBjørn Erik Pedersen
2017-11-18Fix broken shortcodes for Ace and AmberBjørn Erik Pedersen
Fixes #4051
2017-11-17Add support for multiple staticDirsBjørn Erik Pedersen
This commit adds support for multiple statDirs both on the global and language level. A simple `config.toml` example: ```bash staticDir = ["static1", "static2"] [languages] [languages.no] staticDir = ["staticDir_override", "static_no"] baseURL = "https://example.no" languageName = "Norsk" weight = 1 title = "På norsk" [languages.en] staticDir2 = "static_en" baseURL = "https://example.com" languageName = "English" weight = 2 title = "In English" ``` In the above, with no theme used: the English site will get its static files as a union of "static1", "static2" and "static_en". On file duplicates, the right-most version will win. the Norwegian site will get its static files as a union of "staticDir_override" and "static_no". This commit also concludes the Multihost support in #4027. Fixes #36 Closes #4027
2017-11-16tpl/partials: Fix the lock contention in cached partialBjørn Erik Pedersen
Fixes #4086
2017-11-16tpl/partials: Fix cache lockingBjørn Erik Pedersen
To make sure a cached partial is ony executed exactly once. Performance same: ```bash name old time/op new time/op delta TemplateParamsKeysToLower-4 17.2µs ± 0% 16.5µs ± 0% ~ (p=1.000 n=1+1) Partial-4 18.6µs ± 0% 19.4µs ± 0% ~ (p=1.000 n=1+1) PartialCached-4 64.2ns ± 0% 63.7ns ± 0% ~ (p=1.000 n=1+1) name old alloc/op new alloc/op delta TemplateParamsKeysToLower-4 2.66kB ± 0% 2.66kB ± 0% ~ (all equal) Partial-4 1.31kB ± 0% 1.31kB ± 0% ~ (all equal) PartialCached-4 0.00B 0.00B ~ (all equal) name old allocs/op new allocs/op delta TemplateParamsKeysToLower-4 92.0 ± 0% 92.0 ± 0% ~ (all equal) Partial-4 41.0 ± 0% 41.0 ± 0% ~ (all equal) ```
2017-11-16tplimpl: Make partial benchmarks use RunParallelBjørn Erik Pedersen
See #4086
2017-10-30tpl/math: Refactor Mod with castArtem Sidorenko
It makes the code smaller
2017-10-29Add support for height argument to figure shortcodeKaushal Modi
Fixes #4014
2017-10-17Revert "tplimpl: Output xmlns:xhtml only if there are translations available"Bjørn Erik Pedersen
This reverts commit 0859d9dfe647db3b8a192da38ad7efb5480a29a1. Fixes #3978
2017-10-07metrics: Detect partialCached candidatesBjørn Erik Pedersen
This commit adds a "cache potential" column when running `hugo --templateMetrics --templateMetricsHints`. This is only calculated when `--templateMetricsHints` is set, as these calculations has an negative effect on the other timings. This gives a value for partials only, and is a number between 0-100 that indicates if `partial` can be replaced with `partialCached`. 100 means that all execution of the same partial resulted in the same output. You should do some manual research before going "all cache".
2017-10-07tpl: Rework the partial test and benchmarksBjørn Erik Pedersen
2017-10-03tplimpl: Output xmlns:xhtml only if there are translations availableJamie Connolly
2017-10-03tpl: Add errorf template functionBrendan Roy
Add template function that will build a string from the given format string and arguments, then log it to ERROR. This has an intended side-effect of causing the build to fail, when executed. Resolves #3817
2017-09-29Clean up lint in various packagesCameron Moore
Changes fall into one of the following: - gofmt -s - receiver name is inconsistent - omit unused 2nd value from range - godoc comment formed incorrectly - err assigned and not used - if block ends with a return statement followed by else
2017-09-28tpl: Add os.fileExists template functiondigitalcraftsman
Fixes #3839
2017-09-28tpl: Add float template functionLucas Jenss
Add a template function that allows conversion to float. This is useful, for example, when passing aspect ratios into templates, which tend to not be integers. Fixes #3307
2017-09-26tpl: Set Metrics at creation timeBjørn Erik Pedersen
2017-09-26metrics: Add simple template metrics featureCameron Moore
2017-09-26tpl: Add math.Ceil, Floor, and Round to method mappingsCameron Moore
2017-09-25Use Chroma as new default syntax highlighterBjørn Erik Pedersen
If you want to use Pygments, set `pygmentsUseClassic=true` in your site config. Fixes #3888
2017-09-24tpl: Add urls.Parse functionCameron Moore
Add a urls.Parse template function that front-ends url.Parse from the Go stdlib. Fixes #3849
2017-09-24tpl: Add math.Ceil, Floor, and RoundCameron Moore
Ceil and Floor are frontends for the stdlib math functions. The Round implementation is essentially the same thing except that the Go stdlib doesn't include a Round implementation in a stable release yet. I've included the Round function slated for Go 1.10. Fixes #3883
2017-09-23Trim newlines in the hightlight shortcodeBjørn Erik Pedersen
Fixes #3898
2017-09-23Fix the docs helper toolBjørn Erik Pedersen
2017-09-13tpl/tplimpl: Fix escaped HTML Go 1.9 multioutput issue (#3880)Bjørn Erik Pedersen
Fixes #3876
2017-09-09tpl/time: Add time.Duration and time.ParseDuration template funcsBjørn Erik Pedersen
And with time.Duration with the convenient alias `duration`: ``` {{ mul 60 60 | duration "second" }} ``` Fixes #3828
2017-09-08tpl/compare: Add cond (ternary) template funcBjørn Erik Pedersen
Fixes #3860
2017-09-06hugolib: Implement "related content"Bjørn Erik Pedersen
This closes #98, even if this commit does not do full content text search. We may revisit that problem in the future, but that deserves its own issue. Fixes #98
2017-08-22Update template_embedded.gooneleaftea
Changed disqus urls from http to https. This fixes mixed content warnings on browsers when viewing Hugo websites over SSL (https).
2017-08-19tpl: Prepare for template metricsBjørn Erik Pedersen
2017-08-18tpl: Cleanup strings.TrimPrefix and TrimSuffixCameron Moore
These funcs were added during the move to namespaces but were undocumented. This commit fixes the order of the arguments and adds the funcs to the method mapping.
2017-08-18tpl: Add strings.TrimLeft and TrimRight Cameron Moore
2017-08-18compare, hugolib, tpl: Add Eqer interfaceBjørn Erik Pedersen
And use it in `eq` and `ne` so `Page` values can be compared directly in the templates without thinking about it being a `Page` or a `PageOutput` wrapper. Fixes #3807