1

I try to write a snippet to achieve this:

Expandable field:

<something I don't know how to write>(my_class#($1))

Expected result:

If $1 is empty:

`my_factory_utils(my_class)

If $1 is not empty:

`my_factory_param_utils(my_class#(<$1 content>))

Could anyone give me a clue about how could I do that?

Thanks

enchanter
  • 884
  • 8
  • 20

1 Answers1

1

You want to use transformations on mirrors

# -*- mode: snippet -*-
# name: testsnip
# key: testsnip
# --
${1:$(if (zerop (length yas-text)) "my_factory_utils" "my_factory_param_utils")}(my_class${1:$(if (zerop (length yas-text)) "" "#")}$1)

See docs.

event_jr
  • 17,467
  • 4
  • 47
  • 62