Skip to content

Editor.write with curly braces #151

Description

@tjduigna

Consider:

ed = exa.Editor("""
Some text with appropriate {
    braces like some JSON
}""").write('mynewfile.json')

Currently fails with a KeyError because the call to format() expects a dict with the keys being the contents in the brackets. A work-around is to do something simple like:

ed = exa.Editor("""
Some text with appropriate {
    braces like some JSON
}""".replace('{', '{{').replace('}', '}}').write('mynewfile.json')

This will assume there is no format kwargs to be passed and render as plain text.

Ideas: perhaps a "raw" keyword argument to Editor.write to supersede calling format()

It is also possible that one wants to mix and match raw curly braces with formatting curly braces, in which case the "raw" curly braces would need to be escaped somehow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions