I want to write a snippet for LaTeX sum that behaves like this: I write "sum" and trigger snippet expansion. "sum" becomes "\sum_{$1}^{$2} $0", with $1 being the first entry point, $2 the second one and $0 the exit point.
If I write nothing inside $1, I want to have the "_{}" part deleted and proceed to $2. Likewise with $2.
Is such a thing possible with YASnippet or any other snippet engine? I tried putting an Elisp function that deletes the needed part if exiting with no input made but it breaks the snippet.