File size: 1,424 Bytes
b855ced
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{{/*

    This template is used to render a Client-Server API Module. Modules are defined
    alongside the `_index.md` for the CS API.

    The following parameters are expected:

    * `filename` the name of the module file to render, without extension (i.e. `spaces`).
    * `name` the display name of the module (i.e. `Spaces`).

*/}}

{{ $name := .Params.name }}
{{ $filename := .Params.filename }}

{{ with .Site.GetPage "client-server-api/modules" }}
    {{ with .Resources.GetMatch (printf "%s%s" $filename ".md") }}
        {{/* Preserve previous scratch values so nested modules don't leak */}}
        {{ $prevPage := .Scratch.Get "endpoint_page" }}
        {{ $prevModule := .Scratch.Get "endpoint_module" }}

        {{/* Allow endpoints rendered in the module to accumulate on the parent page */}}
        {{ .Scratch.Set "endpoint_page" $.Page }}
        {{/* Name the module for grouping in the endpoints list */}}
        {{ .Scratch.Set "endpoint_module" $name }}

{{ .RenderShortcodes }}

        {{/* Restore previous scratch values */}}
        {{ if $prevPage }}
          {{ .Scratch.Set "endpoint_page" $prevPage }}
        {{ else }}
          {{ .Scratch.Delete "endpoint_page" }}
        {{ end }}
        {{ if $prevModule }}
          {{ .Scratch.Set "endpoint_module" $prevModule }}
        {{ else }}
          {{ .Scratch.Delete "endpoint_module" }}
        {{ end }}
    {{ end }}
{{ end }}