mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-11 06:52:48 +00:00
Before this commit you would typically use `.Scratch.Add` to manually create slices in a loop. With variable overwrite in Go 1.11, we can do better. This commit adds the `append` template func. A made-up example: ```bash {{ $p1 := index .Site.RegularPages 0 }}{{ $p2 := index .Site.RegularPages 1 }} {{ $pages := slice }} {{ if true }} {{ $pages = $pages | append $p2 $p1 }} {{ end }} ``` Note that with 2 slices as arguments, the two examples below will give the same result: ```bash {{ $s1 := slice "a" "b" | append (slice "c" "d") }} {{ $s2 := slice "a" "b" | append "c" "d" }} ``` Both of the above will give `[]string{a, b, c, d}`. This commit also improves the type handling in the `slice` template function. Now `slice "a" "b"` will give a `[]string` slice. The old behaviour was to return a `[]interface{}`. Fixes #5190 |
||
---|---|---|
.. | ||
filesystems | ||
pagemeta | ||
paths | ||
testdata | ||
testsite | ||
404_test.go | ||
alias.go | ||
alias_test.go | ||
author.go | ||
case_insensitive_test.go | ||
collections.go | ||
collections_test.go | ||
config.go | ||
config_test.go | ||
datafiles_test.go | ||
disableKinds_test.go | ||
embedded_shortcodes_test.go | ||
embedded_templates_test.go | ||
fileInfo.go | ||
gitinfo.go | ||
hugo_info.go | ||
hugo_info_test.go | ||
hugo_sites.go | ||
hugo_sites_build.go | ||
hugo_sites_build_failures_test.go | ||
hugo_sites_build_test.go | ||
hugo_sites_multihost_test.go | ||
hugo_themes_test.go | ||
language_content_dir_test.go | ||
media.go | ||
menu.go | ||
menu_test.go | ||
minify_publisher_test.go | ||
multilingual.go | ||
orderedMap.go | ||
orderedMap_test.go | ||
page.go | ||
page_bundler.go | ||
page_bundler_capture.go | ||
page_bundler_capture_test.go | ||
page_bundler_handlers.go | ||
page_bundler_test.go | ||
page_collections.go | ||
page_collections_test.go | ||
page_output.go | ||
page_paths.go | ||
page_paths_test.go | ||
page_permalink_test.go | ||
page_resource.go | ||
page_taxonomy_test.go | ||
page_test.go | ||
page_time_integration_test.go | ||
page_without_content.go | ||
pageCache.go | ||
pageCache_test.go | ||
pageGroup.go | ||
pageGroup_test.go | ||
pages_language_merge.go | ||
pages_language_merge_test.go | ||
pages_related.go | ||
pages_related_test.go | ||
pageSort.go | ||
pageSort_test.go | ||
pagesPrevNext.go | ||
pagesPrevNext_test.go | ||
pagination.go | ||
pagination_test.go | ||
path_separators_test.go | ||
permalinker.go | ||
permalinks.go | ||
permalinks_test.go | ||
prune_resources.go | ||
resource_chain_test.go | ||
robotstxt_test.go | ||
rss_test.go | ||
shortcode.go | ||
shortcode_test.go | ||
shortcodeparser.go | ||
shortcodeparser_test.go | ||
site.go | ||
site_benchmark_test.go | ||
site_output.go | ||
site_output_test.go | ||
site_render.go | ||
site_sections.go | ||
site_sections_test.go | ||
site_stats_test.go | ||
site_test.go | ||
site_url_test.go | ||
siteJSONEncode_test.go | ||
sitemap.go | ||
sitemap_test.go | ||
taxonomy.go | ||
taxonomy_test.go | ||
template_engines_test.go | ||
template_test.go | ||
testhelpers_test.go | ||
translations.go |