Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/it-gro/hugo-theme-w3css-basic.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/shortcodes/readfile.html')
-rw-r--r--layouts/shortcodes/readfile.html57
1 files changed, 37 insertions, 20 deletions
diff --git a/layouts/shortcodes/readfile.html b/layouts/shortcodes/readfile.html
index 507b7eb..8b6f535 100644
--- a/layouts/shortcodes/readfile.html
+++ b/layouts/shortcodes/readfile.html
@@ -2,40 +2,57 @@
inspired by https://github.com/gohugoio/hugo/blob/master/docs/layouts/shortcodes/readfile.html
*/}}
-{{- $.Scratch.Set `theFile` `.` }}
-{{- $.Scratch.Set `theMarkdownify` `` }}
-{{- $.Scratch.Set `theHighlightLang` `md` }}
+{{- $myFile := `.` }}
+{{- $myMarkdownify := `` }}
+{{- $myHighlightLang := `md` }}
+{{- $myTheme := `` }}
{{- if .IsNamedParams -}}
- {{- $.Scratch.Set `theFile` (.Get `file`) }}
- {{- $.Scratch.Set `theMarkdownify` (.Get `md` ) }}
- {{- $.Scratch.Set `theHighlightLang` (.Get `hll` ) }}
+ {{- $myFile = default ($myFile ) (.Get `file` ) }}
+ {{- $myMarkdownify = default ($myMarkdownify ) (.Get `md` ) }}
+ {{- $myHighlightLang = default ($myHighlightLang ) (.Get `hll` ) }}
+ {{- $myTheme = default ($myTheme ) (.Get `theme` ) }}
{{- else -}}
- {{- $myPos := 0}} {{- if gt (len .Params) $myPos }} {{- $.Scratch.Set `theFile` (.Get $myPos) }} {{- end -}}
- {{- $myPos := 1}} {{- if gt (len .Params) $myPos }} {{- $.Scratch.Set `theMarkdownify` (.Get $myPos) }} {{- end -}}
- {{- $myPos := 2}} {{- if gt (len .Params) $myPos }} {{- $.Scratch.Set `theHighlightLang` (.Get $myPos) }} {{- end -}}
+ {{- $myPos := 0}} {{- if gt (len .Params) $myPos }} {{- $myFile = .Get $myPos }} {{- end -}}
+ {{- $myPos := 1}} {{- if gt (len .Params) $myPos }} {{- $myMarkdownify = .Get $myPos }} {{- end -}}
+ {{- $myPos := 2}} {{- if gt (len .Params) $myPos }} {{- $myHighlightLang = .Get $myPos }} {{- end -}}
+ {{- $myPos := 3}} {{- if gt (len .Params) $myPos }} {{- $myTheme = .Get $myPos }} {{- end -}}
{{- end -}}
+{{- if eq $myTheme "default" -}}
+ {{ $myTheme = (default "w3-theme-l3" ($.Site.Param `colorShortcodeReadfile`) ) }}
+{{- end -}}
+
+{{- if in $myTheme "w3-theme" -}}
+<div class="w3-container {{ $myTheme }}" >
+{{- end -}}
+
+
{{- if or $.Site.Params.debug (findRE `\bdebug-shortcode(s|-readfile)\b` $.Site.Params.traceFlags) -}}
<br/>
-"theFile" : {{- $.Scratch.Get `theFile` }} <br/>
-"theMarkdownify" : {{- $.Scratch.Get `theMarkdownify` }} <br/>
-"theHighlight" : {{- $.Scratch.Get `theHighlight` }} <br/>
+"myFile" : {{- $myFile }} <br/>
+"myMarkdownify" : {{- $myMarkdownify }} <br/>
+"myHighlightLang" : {{- $myHighlightLang }} <br/>
+"myTheme" : {{- $myTheme }} <br/>
{{- end -}}
-{{- if (findRE `((\.)|(\\\.))$` ($.Scratch.Get `theFile`) ) -}}
+{{- if (findRE `((\.)|(\\\.))$` $myFile ) -}}
<pre class="w3-code notranslate">
- {{- printf "%s" ($.Scratch.Get `theFile`) -}}
- {{- range readDir ($.Scratch.Get `theFile`) }}
+ {{- printf "%s" $myFile -}}
+ {{- range readDir $myFile }}
{{- printf "\n%s %s %10s %s" .Mode (.ModTime.Format "2006-01-02") (cond .Mode.IsDir "" (string .Size) ) .Name }}
{{- end }}
</pre>
{{- else }}
- {{- if eq ($.Scratch.Get `theMarkdownify`) "true" -}}
- {{- ($.Scratch.Get `theFile`) | readFile | markdownify -}}
- {{- else if ($.Scratch.Get `theHighlightLang`) -}}
- {{- highlight (($.Scratch.Get `theFile`) | readFile) ($.Scratch.Get `theHighlightLang`) "" -}}
+ {{- if eq ($myMarkdownify) "true" -}}
+ {{- $myFile | readFile | markdownify -}}
+ {{- else if $myHighlightLang -}}
+ {{- highlight ($myFile | readFile) $myHighlightLang "" -}}
{{- else -}}
- {{- ($.Scratch.Get `theFile`) | readFile | safeHTML }}
+ {{- $myFile | readFile | safeHTML }}
{{- end -}}
{{- end -}}
+
+{{- if in $myTheme "w3-theme" -}}
+</div>
+{{- end -}}