# Conditionally remove parts of a snippet when the corresponding input field is left empty?

When writing LaTeX code I use a snippet that expands begin to the following  \begin{$1} \label{$1:$2}$0 \end{$1}  This suits most of my purposes well, since I use labels rather systematically. Still there are often times when I do not need a label in an environment and I'd love for a slightly more sophisticated snippet to be possible. I suppose my question boils down to the following: In the above snippet, is it possible to tell yasnippet to write  \begin{$1} $0 \end{$1}  if I have started typing part of the $0 input after leaving $2 blank?

I realize there are many reasonable alternatives to automating this, including using either a separate, non-labelled version of this snippet when I don't need labels or replacing the second snippet line with $2\label{$1:\$3} and killing that line when unnecessary; this is more of an educational exercise for me about the more advanced features in yasnippets. I feel like knowing how to optionally remove portions of a snippet based on input would be useful in other applications. Thanks in advance for your advice!