[TxMt] Re: unordered list nav snippet
jrus at fas.harvard.edu
Fri May 19 00:50:28 UTC 2006
Dave Foy wrote:
> I'm having trouble creating a custom snippet that, for me, would be really useful.
> I want to set up a snippet to create an unordered list nav from a plain text list, e.g.
> I'd like to highlight the whole list, hit a key combo, which would wrap each list item in <li>, wrap the whole lot in <ul>, and even wrap the text within each list item in <a href=""></a> for good measure.
Here's the command I came up with:
return '\t<li><a href="">%s</a></li>' % string.split()
print "\n".join(["<ul>"] +
[wrap(line) for line in sys.stdin] + ["</ul>"])
Set the input to selection or line. If you want some snippet tab action
to enter something in as URL's for the <a>'s, that isn't too hard.
More information about the textmate