Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim trailing commas #82

Open
devhl-labs opened this issue May 16, 2024 · 0 comments
Open

Trim trailing commas #82

devhl-labs opened this issue May 16, 2024 · 0 comments

Comments

@devhl-labs
Copy link

devhl-labs commented May 16, 2024

I don't see a way to trim trailing commas. I imagine it should be like this, but for it to work I need to evaluate the value prior to removing the trailing comma. Over in the OpenAPI generator, I can do {{^-last}},{{/-last}} to avoid printing the comma in the first place, but that does not work here.

.insert_fn("trim-trailing-comma", move |value| {
    if value.ends_with(',') {
        let mut chars = value.chars();
        chars.next_back();
        chars.as_str().to_string()
    } else {
        value.to_string()
    }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant