Well, there is a trick for part 1, here's one of my snippets:
----
# -*- mode: snippet -*-
# name: ix
# binding: 。
# --
[${1:`(cond
((string-match "^[+-]?[0-9]+$" yas/selected-text) "")
((string-match "'" yas/selected-text) "\"")
(t "'")
)`}${1:`yas/selected-text`}${1:`(cond
((string-match "^[+-]?[0-9]+$" yas/selected-text) "")
((string-match "'" yas/selected-text) "\"")
(t "'")
)`}]$0
----
So, basically, you'd do something like ${2:`(cond ...)`} and give ">"
if yas/text is "<". (my snippet examines the selected text.)
aes
> --
> You received this message because you are subscribed to the Google Groups
> "smart-snippet and YASnippet" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/smart-snippet/-/mVDdDH2o2wUJ.
> To post to this group, send email to
smart-...@googlegroups.com.
> To unsubscribe from this group, send email to
>
smart-snippe...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/smart-snippet?hl=en.