Skip to content

Add parameter to not throw error when can't parse string #751

Open
@RomanKuzo

Description

@RomanKuzo

Hey

I'm using this package to interpolate string and insert some data into it.

Example:

I have a string like this: "Hi, this is {{user.first_name}} {{user.last_name}}". And the object of values:

const defaultValues = {
  user: {
    email: '{{user.email}}',
    first_name: '{{user.first_name}}',
    fullname: '{{user.fullname}}',
    last_name: '{{user.last_name}}',
    phone: '{{user.phone}}',
};

It works as expected when everything is okay. But when there is a mistake in a variable it throws me an error (it's also good).
My request is to add an option to skip variables in case of a parsing error and just return this string.

Example:

If I have a string like this: "Hi, this is {{user.first_name} {{user.last_name}}" it should return me a string like this: "Hi, this is {{user.first_name} Kuzo".

Please, let me know if it's possible.

Thanks

Roman Kuzo

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions