render_view.html 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. {{/* Wowchemy content preview renderer */}}
  2. {{ $page := .page }}
  3. {{ $item := .item }}
  4. {{ $view := .view }}
  5. {{ $view_file := "" }}
  6. {{ $view_dtype := printf "%T" $view }}
  7. {{ $index := .index }}
  8. {{if eq $view_dtype "int" | or (eq $view_dtype "int64") }}
  9. {{/* Support legacy numeric views 1-5 */}}
  10. {{ if eq $view 1 }}
  11. {{ $view_file = "list" }}
  12. {{ else if eq $view 3 }}
  13. {{ $view_file = "card" }}
  14. {{ else if eq $view 4 }}
  15. {{ $view_file = "citation" }}
  16. {{ else if eq $view 5 }}
  17. {{ $view_file = "showcase" }}
  18. {{ else }}
  19. {{ $view_file = "compact" }}
  20. {{ end }}
  21. {{else}}
  22. {{ if templates.Exists (printf "partials/views/%s.html" (lower $view)) }}
  23. {{ $view_file = lower $view }}
  24. {{else}}
  25. {{/* Fallback to compact view */}}
  26. {{ warnf "Failed to locate view at `partials/views/%s.html`. Check you specified a supported `view` in `%s`" $view $page.File.Path }}
  27. {{ $view_file = "compact" }}
  28. {{end}}
  29. {{ end }}
  30. {{ return (partial (printf "views/%s" $view_file) (dict "page" $page "item" $item "index" $index)) }}