diff options
Diffstat (limited to 'layouts/partials/utils/get-number-columns.html')
-rw-r--r-- | layouts/partials/utils/get-number-columns.html | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/layouts/partials/utils/get-number-columns.html b/layouts/partials/utils/get-number-columns.html new file mode 100644 index 0000000..d19b99f --- /dev/null +++ b/layouts/partials/utils/get-number-columns.html @@ -0,0 +1,25 @@ +{{/* + Determine the optimal number of columns based on the number of entries. + Parameters: + - length: INTEGER + - scratch: (Scratch) +*/}} + +{{ if eq .length 1 }} + {{ .scratch.Set "col-lg" "12" }} + {{ .scratch.Set "col-md" "12" }} +{{ else if eq .length 2 }} + {{ .scratch.Set "col-lg" "6" }} + {{ .scratch.Set "col-md" "6" }} +{{ else if or (eq .length 4) (or (eq .length 7) (eq .length 8)) }} + {{ .scratch.Set "col-lg" "3" }} + {{ .scratch.Set "col-md" "6" }} +{{ else }} + {{ .scratch.Set "col-lg" "4" }} + {{ .scratch.Set "col-md" "6" }} +{{ end }} + +{{ .scratch.Set "col_layout" (printf "col-lg-%s col-md-%s" (.scratch.Get "col-lg") (.scratch.Get "col-md")) }} + +{{ .scratch.Delete "col-md" }} +{{ .scratch.Delete "col-lg" }} |