Render contexts
The top-level names each kind of template sees, and the fields of every render hook.
What a template can read depends on what is being rendered. A layout sees page, site, build and lang; a shortcode also sees shortcode and inner; a render hook sees its node’s fields directly (destination, text, …). A name a template uses outside its context is reported by fugo templates check.
Templates and their names#
| Template | Top-level names |
|---|---|
| Layout job | page, site, build, lang, output_format, __nh |
| Shortcode | page, site, build, lang, shortcode, inner, inner_deindent, __nh |
| Render hook | page, page_inner, site, build, lang, __nh; plus the hook’s fields, flattened (below) |
partial(name=…, …) | page, site, build, lang, output_format, __nh; plus the call’s kwargs as top-level names |
| Component | ; only its declared arguments; @page, @site, @build, @lang and @__nh may be declared as implicit arguments (looked up in the caller’s scope) |
defer template | data, site, build, __nh |
execute_as_template | data, site, build, __nh |
| Alias | permalink, page, site, build |
| Sitemap, robots, 404 | page, site, build, lang, __nh |
| Sitemapindex | page, site, build, lang, __nh, sites |
Content adapter (content/**/_content.html) | site, build, lang, __nh; site has no page lists (home, pages, regular_pages, all_pages, sections, main_sections, taxonomies, menus): the model is not built yet |
What the names hold#
| Name | Meaning |
|---|---|
page | the full page value of the Full generation |
site | SiteView of the current language |
build | BuildView: version, environment, generator |
lang | the language code of the page |
output_format | OutputFormatView being rendered |
__nh | the render scope (RenderScope); read by site-bound functions |
shortcode | ShortcodeView: name, args, params, is_named_params, ordinal, parent, position |
inner | the inner content (safe) |
inner_deindent | the inner content without common indentation |
page_inner | the page whose source holds the hooked node (differs inside render_shortcodes) |
data | the data= value of the call |
permalink | the target URL |
sites | [{language, sitemap_abs_url, last_mod}] |
__nh is fugo’s render scope. You never print it; site-bound functions such as get_page, paginate or partial read it. A component does not see the caller’s names, so a component that calls a site-bound function declares @__nh, or is passed page=.
Render hook fields#
A render hook’s fields are top-level names: in _markup/render-link.html, write {{ destination }}, not {{ .Destination }}.
| Render hook | Fields |
|---|---|
| link, image | destination, title, text, plain_text, is_block, attributes, ordinal, position |
| heading | level, anchor, text, plain_text, attributes |
| codeblock | type, inner, options, attributes, ordinal, position |
| blockquote | type, alert_type, alert_title, alert_sign, text, attributes, ordinal |
| table | thead, tbody, attributes, ordinal |
| passthrough | type, inner, attributes, ordinal, position |