Last active
March 7, 2017 03:00
-
-
Save budparr/7065ba1c949f9e58342afa2b51fd3828 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ printf "%#v" . }} | |
If you ever need to drill into what is passed to a template, just put this at the top of your template somewhere: | |
{{ printf "%#v" . }} | |
Then look at a page generated by that template - that'll print out what the top level object is, and what it's fields are. When I do it with a shortcode template, I get something like this: | |
&hugolib.ShortcodeWithPage{Params:[]string{"."}, Inner:"", Page:(*hugolib.Page)(0xc2082e4840)} | |
That tells me there's a .Params value which is a list of strings (that contains a single string which is just the dot character), there's a .Inner value which is a string (which is empty), and a Page value, which is a hugolib.Page (the object you get back with various templates from .Page). You can then modify the template to drill down, so now make the template | |
{{ printf "%#v" .Page }} | |
That'll print out what the Page value contains.... which is a huge block of stuff, but you should be able understand it, more or less. Repeat as necessary. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment