如何编写一个内容取决于某些扩展字段的片段?

时间:2014-06-17 00:57:56

标签: emacs elisp code-snippets yasnippet

我尝试编写一个片段来实现这一目标:

可扩展字段:

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

预期结果:

如果$ 1为空:

`my_factory_utils(my_class)

如果$ 1不为空:

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

有人能给我一个线索,我怎么能这样做?

由于

1 个答案:

答案 0 :(得分:1)

您想在镜像上使用转换

# -*- 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)

请参阅docs