Can I render template data conditionally to my service group matching a string?

In other words, can I do something like:

  {{#if pkg.svc.group.<groupname> ~}}
  <some config for <groupname>>
  {{/if ~}}

?

Unfortunately the #if operator only works on truthy things (e.g. booleans, presence-or-absence, etc.), and doesn’t handle arbitrary boolean expressions.

What’s the usecase you’re trying to serve?

We’re building and shipping an Angular app that has some hard-coded internal URLs depending on whether it’s been built for a validation env or a production one. So we’d like to be able to dynamically point Nginx as the right set of assets depending on which service group we are running as.

Could those URLs be externalized in Habitat config? Then you could add the appropriate URLs to the service group as a whole, and your application doesn’t need to have such intimate knowledge of where it’s running.

Not easily - this stuff gets webpack-ed into minified JS and then served.

What we might end up doing is having 2 location directives in our Nginx config pointing to the two sets of assets, with appropriate rewrite rules.

That sounds like a good approach.

What you could also do is try to export the config in its own json file.

Say a file at /config.json that would be assembled by habitat, and the app requires this file whatever the environment, it’ll always be in the same place. I’ve done it in the past, worked pretty well, and it’s quite cheap to implement ^^

Reasonable. We might also ask the JS devs to make the app modular (might turn out to be easier).