Simplify img style builder
This commit is contained in:
@@ -65,44 +65,30 @@
|
||||
{{ $height = "auto" }}
|
||||
{{ end }}
|
||||
|
||||
{{ $styles := slice }}
|
||||
|
||||
{{ if $height }}
|
||||
{{ with printf "height: %v" $height }}
|
||||
{{ if $style }}
|
||||
{{ $style = printf "%v; %v" $style . }}
|
||||
{{ else }}
|
||||
{{ $style = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $styles = $styles | append (print "height: " $height) }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $maxheight }}
|
||||
{{ with printf "max-height: %v" $maxheight }}
|
||||
{{ if $style }}
|
||||
{{ $style = printf "%v; %v" $style . }}
|
||||
{{ else }}
|
||||
{{ $style = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $styles = $styles | append (print "max-height: " $maxheight) }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $maxwidth }}
|
||||
{{ with printf "max-width: %v" $maxwidth }}
|
||||
{{ if $style }}
|
||||
{{ $style = printf "%v; %v" $style . }}
|
||||
{{ else }}
|
||||
{{ $style = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $styles = $styles | append (print "max-width: " $maxwidth) }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $width }}
|
||||
{{ with printf "width: %v" $width }}
|
||||
{{ if $style }}
|
||||
{{ $style = printf "%v; %v" $style . }}
|
||||
{{ else }}
|
||||
{{ $style = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $styles = $styles | append (print "width: " $width) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $styles = delimit $styles "; " }}
|
||||
|
||||
{{ if $style }}
|
||||
{{ $style = print $style "; " $styles }}
|
||||
{{ else }}
|
||||
{{ $style = $styles }}
|
||||
{{ end }}
|
||||
|
||||
<img {{ with $alt }} alt="{{ . }}" {{ end }} {{ with $class }} class="{{ . }}" {{ end }} crossorigin="{{ $crossorigin }}" {{ with $fetchpriority }} fetchpriority="{{ . }}" {{ end }} {{ with $intrinsicheight }} height="{{ . }}" {{ end }} loading="{{ $loading }}" referrerpolicy="{{ $referrerpolicy }}" src="{{ $src }}" {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ with $title }} title="{{ . }}" {{ end }} {{ with $intrinsicwidth }} width="{{ . }}" {{ end }}>
|
||||
|
Reference in New Issue
Block a user