{{- /* Usage: `css-vars-docs file="file/_location.scss"` Find all CSS Variables and print them in the docs. */ -}} {{- $path := .Get "path" -}} {{- $filepath := printf "docs/content/%s" $path -}} {{- $files := readDir $filepath -}} {{- $ext := default "-" (.Get "type" ) -}} {{- if (fileExists $filepath) -}} {{- range $files -}} {{- if (and (ne (substr .Name 0 1) "_") (not .IsDir)) }}{{ $content := readFile (printf "docs/content/%s/%s" $path .Name) -}} {{- $regexFileName := printf "css-vars-docs file=(.*)scss." -}} {{- $regexTitle := printf "title:(.*)" -}} {{- $matchFileName := (findRE $regexFileName $content 1) | uniq | sort -}} {{- if (gt (len $matchFileName) 0) -}} {{- $matchTitle := (findRE $regexTitle $content 1) -}} {{- $title := replaceRE "\\[title: (.*)\\]$" "$1" (printf "%s" $matchTitle) -}} {{- $scssFileName := replaceRE "\\[css-vars-docs file=\"(.*)\"\\]" "$1" (printf "%s" $matchFileName) -}} {{ printf "#### %s\n" (replace $title "Bootstrap" "" | title) }} {{ printf "\n" }} {{- $regex := printf "(--#{\\$prefix}[^,|)|:]*)" -}} {{- $css := readFile $scssFileName -}} {{- $match := (findRE $regex $css) | uniq | sort -}} {{- $result := delimit $match "\n" -}} {{- $result = replace $result "#{$variable-prefix}" "cui-" -}} {{ printf "\n" }} {{ highlight $result "scss" "" }} {{ printf "\n" }} {{- end -}} {{- end -}} {{- end -}} {{- end -}}