Update datafiles.md - hugo - [fork] hugo port for 9front
(HTM) git clone git@git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit e96624cce85dc72f142b800f5a04ff653c7dad77
(DIR) parent d4b6f9aca3c3c1ca02a52d34fba21104e0ca9a94
(HTM) Author: Sebastian Krause <HatiEth@users.noreply.github.com>
Date: Tue, 16 Jun 2015 01:09:24 +0200
Update datafiles.md
additional example for named data values
Diffstat:
M docs/content/extras/datafiles.md | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/docs/content/extras/datafiles.md b/docs/content/extras/datafiles.md
@@ -81,3 +81,24 @@ And then in `partial/artist.html`:
```
Discover a new favourite bass player? Just add another TOML-file.
+
+## Example: Accessing named values in a Data File
+
+Assuming you have the following YAML structure to your `User0123.yml` Data File located directly in `data/`
+
+```
+Name: User0123
+"Short Description": "He is a jolly good fellow."
+Achievements:
+ - "Can create a Key, Value list from Data File"
+ - "Learns Hugo"
+ - "Reads documentation"
+```
+
+To render the `Short Description` in your `layout` File following code is required.
+
+```
+{{ $.Scratch.Set "ShortDesc" ( index $.Site.Data.User0123 "Short Description" ) }}
+<div>Short Description of {{.Site.Data.User0123.Name}}: <p>{{ $.Scratch.Get "ShortDesc" }}</p></div>
+{{ end }}
+```