Skip to content

Smarter snippet holes #445

@pokey

Description

@pokey

The goal

We'd like to enhance the ability for snippets to be used to perform high-level syntactic transformations. To this end we'd like to add the following abilities:

  • To indicate that a particular hole can accept a list, and indicate a snippet that should be used to wrap each element of the list before being inserted as into the snippet hole. The two primary applications of this mechanism are Add snippet wrapper support to "repack" action #444 and "bring as" syntax transformation #60
    • The ability to indicate that a list valued snippet should join its elements using a particular string
    • On insertion, these list-valued holes should support a workflow where you can instantiate the snippet with n instances of the hole snippet
    • These list-valued holes should support a command to insert another instance of the hole
  • To indicate a transformation written in typescript that should be applied to the input to a particular hole

Some examples

  • Converting an if-else statement to a switch statement: "switch repack if state"
  • "bring air past bat as list"

Examples we'd like to support

  • Transform a dictionary to just a list consisting of its keys
  • Transform a list to a dictionary

Questions

  • Could we get a lot of this stuff for free by switching to a proper templating engine like handlebars?

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions