[SOLVED] Current Output Format

Hey @FelicianoTech, maybe it’s useful for you to:

  1. manually assign the output format of such template in Scratch;
  2. retrieve the output format from Scratch in your partial (as long as you pass the context, you should be able to access it.

For instance, in index.amp.html:

<!doctype html>
<html amp lang="en">
  <head>
    {{ .Scratch.Set "output-format" "amp" }}

then in a partial or the template itself:

      {{ if $.Scratch.Get "output-format" }}
        {{ partial "index/main/entry.amp.html" . }}
      {{ else }}
        {{ partial "index/main/entry.html" . }}
      {{ end }}

Naturally, you could probably do something more sophisticated like formatting the partial path to already include the output-format.

I hope it helps :slight_smile:

thx!

3 Likes