Skip to content

[proposal] Add {{exprLast}} template placeholder #90

@zardoy

Description

@zardoy

Template Examples

{
  "name": "destruct",
  "body": "const { {{exprLast}}$1 } = {{exprRest}}",
  "when": [
    "expression",
  ]
},
{
  "name": "log2",
  "body": "console.log('{{exprLast}}', {{expr}})",
  "when": [
    "identifier",
    "expression",
    "function-call"
  ]
},

Usage Examples

defaultSettings.getGeneralSettings().clipboardLinkDetection.destruct
// => destruct
const { clipboardLinkDetection } = defaultSettings.getGeneralSettings()

(await fetchData()).customField.destruct
// => destruct
const { customField } = (await fetchData())

defaultSettings.general.clipboardLinkDetection.log2
// => log2
console.log('clipboardLinkDetection', defaultSettings.general.clipboardLinkDetection)

// update to include even more ideas

checkInterval.clear /* -> */ clearInterval(checkInterval)
closeTimeout.clear /* -> */ clearTimeout(closeTimeout) 

While {{exprLast}} can be useful in some scenarios like logging or usage for some custom function that accepts label as first argument. Another example would be usage with test() & capitalize filter.

However, for now I can imagine only one case, where {{exprRest}} can be useful (destruct example above).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions