Skip to content
Snippets Groups Projects

HugoPartialStarter

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Wolf Noble

    an example starting point 'boilerplate' for hugo partials I'm trying to refine

    Edited
    partials/default/profile.html 2.88 KiB
    {{- $proItch := newScratch -}}
    {{- $profileTimer := false  -}}
    {{- $context := . }}
    {{- $scope := default nil }}
    {{- if (reflect.IsMap . ) }}
      {{- $context = .context }}
      {{- $scope = cond (not .scope) nil .scope }}
    {{- end }}
    {{- with $context }}
      {{- $proItch.Set "debug"         ($scope.debug |default false) -}}
      {{- $proItch.Set "debugRecurse"  ($scope.debugRecurse |default false ) -}}
      {{- $proItch.Set "logPrefix"     "[default/profile]" -}}
      {{- $proItch.Set "debugPrefix"   (print "[debug]" ($proItch.Get "logPrefix")) -}}
      {{- $proItch.Set "extraPrefix"   (print "[Debug]" ($proItch.Get "logPrefix")) -}}
      {{- $proItch.Set "verbosePrefix" (print "[DEBUG]" ($proItch.Get "logPrefix")) -}}
      {{- $proItch.Set "permalink"     (.Permalink|default nil) -}}
      {{- $proItch.Set "page"          (.Page |default nil)  -}}
      {{- $proItch.Set "scheme"        (.Site.Params.colorScheme|default false)  -}}
      {{- $proItch.Set "currentLang"   (.Site.Language.Lang|default false) -}}
      {{- $proItch.Set "hasData"       nil  -}}
      {{- $proItch.Set "name"          (.Name|default nil) -}}
      {{- $proItch.Set "mahName"       ($proItch.Get "name" -}}
      {{- $proItch.Set "logPrefix"     (print ($proItch.Get     "logPrefix") "[" ($proItch.Get "dataKey") "]") -}}
      {{- $proItch.Set "debugPrefix"   (print ($proItch.Get   "debugPrefix") "[" ($proItch.Get "dataKey") "]") -}}
      {{- $proItch.Set "extraPrefix"   (print ($proItch.Get   "extraPrefix") "[" ($proItch.Get "dataKey") "]") -}}
      {{- $proItch.Set "verbosePrefix" (print ($proItch.Get "verbosePrefix") "[" ($proItch.Get "dataKey") "]") -}}
      {{- if and ($proItch.Get "debug") (eq ($proItch.Get "debug") 1 ) -}}
        {{- warnf "%s extra debug enabled" ($proItch.Get "extraPrefix") -}}
      {{- else if and ($proItch.Get "debug") (gt ($proItch.Get "debug") 1 ) -}}
        {{- warnf "%s Verbosamine™️ administered!" ($proItch.Get "verbosePrefix") -}}
      {{- else if $proItch.Get "debug" -}}
        {{- if eq ($proItch.Get "debug") "true" -}}
          {{- warnf "%s debug enabled" ($proItch.Get "debugPrefix") -}}
        {{- else -}}
          {{- warnf "%s debug enabled: %d" ($proItch.Get "debugPrefix") ($proItch.Get "debug") -}}
        {{- end -}}{{- /* be a lil better about when to display the value of debug */ -}}
      {{- end -}}
      {{- if and ($proItch.Get "debug") (gt ($proItch.Get "debug") 8 ) -}}
        {{- $profileTimer := debug.Timer (print "cards/peeps/profile-" ($proItch.Get "dataKey") "-" (site.Language.Lang)) -}}
        {{- warnf "%s Debug timer started!" ($proItch.Get "verbosePrefix") -}}
      {{- end -}}
      {{- /* do the thing */ -}}
      <div id="icon">
      {{ $bare := (partial "util/bareSVG.html" (dict "context" . "entity" "hugoIcon" "scope" (dict "debug" ($proItch.Get "debugRecurse") "return" "content" "lang" ($proItch.Get "currentLang"))) }}
      {{- with $bare -}}
        {{- . -}}
      {{- end -}}
      </div>
    {{- end -}}{{- /* Job's done! */ -}}
    {{- if  ($profileTimer) -}}
      {{- $profileTimer.Stop -}}
    {{- end -}}
    partials/util/bareSVG.html 6.27 KiB
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment