At the moment the foreman codebase has two separate foreman_url functions defined (one is a helper, one is in lib/) - iirc, one of them can be called without `@host`. The most obvious example is the PXE Default File template, which is written without knowing `@host` - obviously, because it's a default.

So maybe something like `@host.token.value rescue nil` ?