Skip to content

Ignore slots without value provided #24

Description

@ericzon

First of all, thank you for your lib :)

I'm experiencing a possible bug. If I try this example:

const replaceTemplate = require('string-template');

const input = "https://{user}:{password}@{domain}/api/endpoint1?parameter1={parameterValue1}";
const replacements = {
  user: 'Eric',
  password: 'a pass',
  domain: 'any-url.com'
};

const test = replaceTemplate(input, replacements);

The result is like this:

"https://Eric:a pass@any-url.com/api/endpoint1?parameter1=";

parameterValue1 is lost. I should expect an output like this:

"https://Eric:a pass@any-url.com/api/endpoint1?parameter1={parameterValue1}";

To put you in context, I'm developing an API with Loopback 4 using datasource templating and they use {} as delimiters. My idea was to join their bindings with my own thanks to your lib.

Maybe it could also be related with #12 because with custom delimiters, this error could be work-arounded.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions