render.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {{ define "recurse-toc" }}
  2. {{ $s := .section }}
  3. {{ $psid := .psid }}
  4. {{ $pages := (union $s.Pages $s.Sections).ByWeight }}
  5. {{ $subSection := 1 }}
  6. {{ range where $pages ".Params.no_print" "!=" true }}
  7. {{ $sid := printf "%s%d" $psid $subSection }}
  8. {{ $subSection = add $subSection 1 }}
  9. {{ partial "print/toc-li.html" (dict "sid" $sid "Page" .) }}
  10. {{ if .IsSection }}
  11. <ul>
  12. {{ template "recurse-toc" (dict "section" . "psid" (printf "%s." $sid)) }}
  13. </ul>
  14. {{ end }}
  15. {{ end }}
  16. {{ end }}
  17. {{ define "recurse-content" }}
  18. {{ $s := .section }}
  19. {{ $psid := .psid }}
  20. {{ $pages := (union $s.Pages $s.Sections).ByWeight }}
  21. {{ $subSection := 1 }}
  22. {{ $breakOnWordCount := default 50 ($s.Site.Param "print.section_break_wordcount") }}
  23. {{ $doPageBreak := gt (countwords $s.Content) $breakOnWordCount }}
  24. {{ range where $pages ".Params.no_print" "!=" true }}
  25. {{ $sid := printf "%s%d" $psid $subSection }}
  26. {{ $subSection = add $subSection 1 }}
  27. {{ $params := dict "Page" . "PageNum" $sid "DoPageBreak" $doPageBreak }}
  28. {{ partial "print/content.html" $params }}
  29. {{ if .IsSection }}
  30. {{ template "recurse-content" (dict "section" . "psid" (printf "%s." $sid) ) }}
  31. {{ end }}
  32. {{ $doPageBreak = true }}
  33. {{ end }}
  34. {{ end }}
  35. <div class="td-content">
  36. <div class="pageinfo pageinfo-primary d-print-none">
  37. <p>
  38. {{ T "print_printable_section" }}
  39. <a href="#" onclick="print();return false;">{{ T "print_click_to_print" }}</a>.
  40. </p><p>
  41. <a href="{{ .RelPermalink }}">{{ T "print_show_regular" }}</a>.
  42. </p>
  43. </div>
  44. {{ partial "print/page-heading.html" . }}
  45. {{ if not (.Param "print.disable_toc") }}
  46. <ul>
  47. {{ template "recurse-toc" (dict "section" .CurrentSection "psid" "") }}
  48. </ul>
  49. {{ end }}
  50. <div class="content">
  51. {{ .Content }}
  52. </div>
  53. </div>
  54. {{ template "recurse-content" (dict "section" .CurrentSection "psid" "") }}