diff --git a/engine/templates.go b/engine/templates.go index 7bf2710..5e87b80 100644 --- a/engine/templates.go +++ b/engine/templates.go @@ -35,73 +35,87 @@ var (
{{ String }}
-

Request context params

+

Request context parameters (Context.params)

{{ #Context.params }}
{{ . }}
{{ /Context.params }} {{ ^Context.params }} -

No context parameters set

+

No context parameters set.

{{ /Context.params }}
-

Request context keys

+

Request context keys (Context.keys)

{{ #Context.keys }}
{{ . }}
{{ /Context.keys }} {{ ^Context.keys }} -

No context keys set

+

No context keys set.

{{ /Context.keys }}
-

Request params

+

Request parameters (Params)

{{ #Params }}
{{ . }}
{{ /Params }} + {{ ^Params }} +

This page didn't set any parameters in the URL.

+ {{ /Params }}
-

Extra data

+

Extra data from config (Extra)

{{ #Extra }}
{{ . }}
{{ /Extra }} + {{ ^Extra }} +

The configuration file does not add any extra data.

+ {{ /Extra }}

Backend response

-

As object

+

Response when object (Data)

{{ #Data }}
{{ . }}
{{ /Data }} + {{ ^Data }} +

The backend response did not return an object.

+ {{ /Data }} -

As array

+

Response when array (Array)

{{ #Array }}
{{ . }}
{{ /Array }} + {{ ^Array }} +

The backend response did not return an array or configuration does not set isArray.

+ {{ /Array }}
` ) diff --git a/examples/blog/main_layout.mustache b/examples/blog/main_layout.mustache index 0fbaead..6b5caae 100644 --- a/examples/blog/main_layout.mustache +++ b/examples/blog/main_layout.mustache @@ -51,5 +51,10 @@

{{ Extra.copyright }} · Privacy · Terms

+
+
+ {{> api2html/debug }} +
+
diff --git a/examples/debugger/config.json b/examples/debugger/config.json index b98eb44..99e2d22 100644 --- a/examples/debugger/config.json +++ b/examples/debugger/config.json @@ -7,37 +7,28 @@ "CacheTTL": "1s" }, { - "name": "static", - "URLPattern": "/static", - "Template": "static", - "CacheTTL": "1s", - "extra": { - "metadata_title":"API2HTML static page debugger" - } - }, - { - "name": "dynamic", - "URLPattern": "/dynamic/object/:post", + "name": "post", + "URLPattern": "/post/:post", "BackendURLPattern": "https://jsonplaceholder.typicode.com/posts/:post", - "Template": "dynamic", + "Template": "post", "CacheTTL": "1s", "extra": { - "metadata_title":"API2HTML dynamic page debugger" + "metadata_title":"API2HTML post page debugger" } }, { - "name": "dynamic", - "URLPattern": "/dynamic/lists", + "name": "post", + "URLPattern": "/posts", "BackendURLPattern": "https://jsonplaceholder.typicode.com/posts", - "Template": "dynamic", + "Template": "post", "IsArray": true, "CacheTTL": "1s", "extra": { - "metadata_title":"API2HTML dynamic page debugger" + "metadata_title":"API2HTML post page debugger" } } ], - "templates": {"home":"home.mustache","static":"home.mustache","dynamic":"home.mustache"}, + "templates": {"home":"home.mustache","post":"home.mustache"}, "extra":{ "lang": "en-US", "metadata_title": "API2HTML debugger" diff --git a/examples/debugger/home.mustache b/examples/debugger/home.mustache index 864c54b..0d8f701 100644 --- a/examples/debugger/home.mustache +++ b/examples/debugger/home.mustache @@ -6,7 +6,22 @@ -

Hi there!

+

Debug example

+

This is a simple page that uses a single page and loads data from an external API so you can see how the debug template changes.

+ + + + {{ #Data }} +

{{ title }}

+

{{ body }}

+ + {{ /Data }} + + {{ >api2html/debug }} \ No newline at end of file