mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 20:15:25 +00:00
Hardened 1st batch of five homepage blocks by normalizing config types, clamping unsafe values, and guarding bad inputs so user‑supplied params fail safe without template errors. Changes coerce_bool.html and coerce_int.html: added shared coercion helpers for consistent, safe defaults across blocks. block.html: sanitized content/design inputs, robust user_groups parsing, safer role/affiliation/interest/link handling, and CTA URL validation. block.html: guarded avatar/banner/name/headings/bio, safe button/link resolution, and resilient parsing for affiliations, education, interests, and social links. block.html: hardened filters (kinds/folders/tags), safer sort/order handling, clamped numeric params, and archive link safety/fallbacks. block.html and block.html: defensive content rendering, clamped overlay opacity, and safe button link handling. schema.json, schema.json, schema.json: added view enum entries, added new_tab, and Biome formatting applied.
21 lines
909 B
HTML
21 lines
909 B
HTML
{{ $value := .value }}
|
|
{{ $result := .default }}
|
|
{{ if ne $value nil }}
|
|
{{ $valueType := printf "%T" $value }}
|
|
{{ if eq $valueType "bool" }}
|
|
{{ $result = $value }}
|
|
{{ else if or (eq $valueType "int") (eq $valueType "int8") (eq $valueType "int16") (eq $valueType "int32") (eq $valueType "int64") (eq $valueType "uint") (eq $valueType "uint8") (eq $valueType "uint16") (eq $valueType "uint32") (eq $valueType "uint64") }}
|
|
{{ $result = ne (int $value) 0 }}
|
|
{{ else if or (eq $valueType "float32") (eq $valueType "float64") }}
|
|
{{ $result = ne (float $value) 0 }}
|
|
{{ else if eq $valueType "string" }}
|
|
{{ $trimmed := lower (strings.TrimSpace $value) }}
|
|
{{ if in (slice "1" "true" "yes" "y" "on") $trimmed }}
|
|
{{ $result = true }}
|
|
{{ else if in (slice "0" "false" "no" "n" "off") $trimmed }}
|
|
{{ $result = false }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ return $result }}
|