question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Handlebars helper for resolving system and environment variables

See original GitHub issue

I’m looking to stand up a standalone version for load testing. One of the needs is to be able to replace values in the response template from system or environment variables. Based on https://github.com/tomakehurst/wiremock/issues/789, looks like it’s not currently possible without repackaging the code, although I’m not sure even in that case how’d I register the custom helper class.

I can imagine such a helper to be pretty useful, and will be happy to make a PR. I’m not super familiar with Handlebars, but I think the following should get the job done:

{{var key='something' scope='[sys|env]'}}

If scope isn’t specified, the code will lookup in the system variables first, followed by environment variables. Any . or - in the key will be converted to a _ if scope=env, as well as uppercased. For example, key=wire-mock.rocks will be converted to WIRE_MOCK_ROCKS. No such translation will be performed for scope=sys.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
philippe-granetcommented, Feb 20, 2019

See PR #1085

1reaction
tomakehurstcommented, Nov 15, 2018

@zkendall I agree this would be useful, and I’m happy for it to be added. If you’re up for a creating a PR that would make things happen much more quickly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add Handlebars helper for resolving system and environment ...
I'm looking to stand up a standalone version for load testing. One of the needs is to be able to replace values in...
Read more >
Exposing Node Environment Variable to Handlebars Partials
A Solution​​ One of the major ways that Handlebars differs from it's predecessor Mustache is that it allows us to write custom helper...
Read more >
Configuration Helpers - Chef Documentation
Define dynamic plan configuration settings with plan helpers. ... built-in Handlebars helpers and Chef Habitat-specific helpers in defining ...
Read more >
Access a variable outside the scope of a Handlebars.js each ...
Turns out I was using a fat arrow function when registering the helper, and this is different inside a fat arrow function. Changing...
Read more >
Handlebars - Scaler Topics
Handlebars let you create a custom helper function to accomplish the task you define. Let's take an example where you want the Handlebars...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found