-
Notifications
You must be signed in to change notification settings - Fork 0
Env
HUGE/Env is responsible of everything environment. Its public functions are available to any user.
HUGE/Env relies on its huge/env/Get
function detailed below to determine the environment. As is, it's just a wrapper for hugo.Environment
.
-
hugo.Environment
returns the value of - the
--environment
(or-e
) flag set through Hugo CLI or, - if not set,
HUGO_ENV
orHUGO_ENVIRONMENT
environment variable. - If none of the above are set it returns
development
in server mode, - and
production
in build mode.
If the project relies on another logic to determine its environment, one can add its own partial at layouts/partials/huge/env/Get
, it will overrides HUGE's.
Let's say the project relies on NODE_ENV
for determining environment.
{{/* /layouts/partials/huge/env/Get */}}
{{ $env := hugo.Environment }}
{{ with getenv "NODE_ENV" }}
{{ $env = . }}
{{ end }}
{{ return $env }}
Now huge/env/Get
and other HUGE/Env functions will also rely on NODE_ENV
to evaluate.
Lengthily discussed above.
Any
A string representing the current environment. Logic is discussed above.
{{ if eq (partial "huge/env/Get") "development" }}
{{ $debug = true }}
{{ end }}
A string.
A boolean, true
if the given string matches the current environment, false
if not.
{{ if partial "huge/env/Is" "production" }}
{{ $ga = true}}
{{ end }}
A string.
A boolean, true
if the given string does not match the current environment, false
if it does.
{{ if partial "huge/env/IsNot" "production" }}
{{ $debug = true }}
{{ end }}
Any
A boolean, true
if the current environment matches production
, false
if not.
{{ if partial "huge/env/IsProduction" "production" }}
{{ $debug = true }}
{{ end }}
This is handy when you need to do something always or never or only in one given environment.
A string which must be among a list of:
always
never
-
{environment}
: A string representing one of the project's environments.
A boolean:
true
if the given parameter is always
or matches the current environment.
false
if the given parameter is never
or do not match the current environment.
This is a HUGE WIP right now! Stay tune for more info as we push it to Alpha!