Skip to content

Improve docs of quote functions #481

Description

@meeque

I get that sprig wants to keep function names and documentation concise. But the docs for quote and squote look incomplete to me:

# quote and squote

These functions wrap a string in double quotes (`quote`) or single quotes
(`squote`).

These functions do a little more than wrapping, they also escape the contents of the string for the target quoted string format.

E.g. the quote function delegates to Go's fmt.Sprintf function and uses the %q verb, whose documentation says:

a double-quoted string safely escaped with Go syntax

I think that sprig documentation should reflect this piece of information. (Similar for squote).

As a user of sprig, I'd like to know where I can use the resulting strings securely. Looks like I can use them when generating Go code. But are they also safe to embed into other languages and data formats? E.g. C, Java, JS, JSON, or YAML? (E.g. Helm recommends using Sprig's quote function when generating YAML code.)

My I attempt a PR to improve the docs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions