From 0eaaa8fee37068bfc8ecfb760f770ecc9a7af22a Mon Sep 17 00:00:00 2001 From: Paul van Brouwershaven Date: Thu, 2 Dec 2021 17:30:36 +0100 Subject: Implement XML data support Example: ``` {{ with resources.Get "https://example.com/rss.xml" | transform.Unmarshal }} {{ range .channel.item }} {{ .title | plainify | htmlUnescape }}

{{ .description | plainify | htmlUnescape }}

{{ $link := .link | plainify | htmlUnescape }} {{ $link }}

{{ end }} {{ end }} ``` Closes #4470 --- docs/content/en/templates/data-templates.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'docs/content/en/templates') diff --git a/docs/content/en/templates/data-templates.md b/docs/content/en/templates/data-templates.md index c36344776..441cc2f10 100644 --- a/docs/content/en/templates/data-templates.md +++ b/docs/content/en/templates/data-templates.md @@ -6,7 +6,7 @@ date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-03-12 categories: [templates] -keywords: [data,dynamic,csv,json,toml,yaml] +keywords: [data,dynamic,csv,json,toml,yaml,xml] menu: docs: parent: "templates" @@ -20,7 +20,7 @@ toc: true -Hugo supports loading data from YAML, JSON, and TOML files located in the `data` directory in the root of your Hugo project. +Hugo supports loading data from YAML, JSON, XML, and TOML files located in the `data` directory in the root of your Hugo project. {{< youtube FyPgSuwIMWQ >}} @@ -28,7 +28,7 @@ Hugo supports loading data from YAML, JSON, and TOML files located in the `data` The `data` folder is where you can store additional data for Hugo to use when generating your site. Data files aren't used to generate standalone pages; rather, they're meant to be supplemental to content files. This feature can extend the content in case your front matter fields grow out of control. Or perhaps you want to show a larger dataset in a template (see example below). In both cases, it's a good idea to outsource the data in their own files. -These files must be YAML, JSON, or TOML files (using the `.yml`, `.yaml`, `.json`, or `.toml` extension). The data will be accessible as a `map` in the `.Site.Data` variable. +These files must be YAML, JSON, XML, or TOML files (using the `.yml`, `.yaml`, `.json`, `.xml`, or `.toml` extension). The data will be accessible as a `map` in the `.Site.Data` variable. ## Data Files in Themes @@ -95,7 +95,7 @@ Discover a new favorite bass player? Just add another `.toml` file in the same d ## Example: Accessing Named Values in a Data File -Assume you have the following data structure in your `User0123.[yml|toml|json]` data file located directly in `data/`: +Assume you have the following data structure in your `User0123.[yml|toml|xml|json]` data file located directly in `data/`: {{< code-toggle file="User0123" >}} Name: User0123 @@ -232,6 +232,7 @@ If you change any local file and the LiveReload is triggered, Hugo will read the * [YAML Spec][yaml] * [JSON Spec][json] * [CSV Spec][csv] +* [XML Spec][xml] [config]: /getting-started/configuration/ [csv]: https://tools.ietf.org/html/rfc4180 @@ -247,3 +248,4 @@ If you change any local file and the LiveReload is triggered, Hugo will read the [variadic]: https://en.wikipedia.org/wiki/Variadic_function [vars]: /variables/ [yaml]: https://yaml.org/spec/ +[xml]: https://www.w3.org/XML/ -- cgit v1.2.3