It works making use of printf
{{ $host := trim $host }}
{{ $is_regexp := hasPrefix "~" $host }}
{{ $upstream_name := when $is_regexp (sha1 $host) $host }}
{{ $access_log := (or (and (not $.Env.DISABLE_ACCESS_LOGS) (printf "%s%s%s" "access_log /var/log/nginx/vhosts/" $host "_access.log vhost;")) "") }}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…