[TxMt] invoking a snippet from a snippet

Ed Singleton singletoned at gmail.com
Wed Nov 15 08:58:05 UTC 2006

On 14/11/06, Allan Odgaard <throw-away-1 at macromates.com> wrote:
> On 14. Nov 2006, at 14:55, Ed Singleton wrote:
> >> > I'd also really like to be able to reference tab-stops from the
> >> first
> >> > snippet in the second snippet.
> >> How would that work?
> > Well, using a (grossly oversimplified) use case of a html form.  Let's
> > say you have a form snippet and lots of field snippets.
> >
> > Sometimes you want to prepend the id of the form to the id of the
> > fields:
> >
> > <form id="my_form">
> > <input id="my_form_field_1">
> > [...]
> Ah, okay -- well, I think the best way to solve this is to instead
> let the snippet be generated by a command, which takes the form as
> input, and extracts the ID. Then the "child snippet" will also work
> as expected, even when not invoked inside the parent one.
> But I do like the idea, though would need more use cases for me to
> really be behind it -- but now that you've planted a seed, maybe I'll
> start to see them :)

I've been working quite heavily on Jonathan LaCour's TurboGears
bundle, and I have some snippets that end up three levels deep (a form
snippet which you fill with field snippets which you fill with
validator snippets).  There's quite a few times I'd like to have
referred back to a form name or field name that the user entered, to
use it as a default value in the error messages in the validator.
(I'm hoping to clean up the bundle and release it next week, so you'll
see better what I mean then).

The idea of creating snippets dynamically through a command seems
quite powerful, but a lot more difficult (maybe just to me as I'm
always reluctant to do parsing or regexs).

The other idea I had was some sort of data grammar, like language
grammars, that presented the user with options at various points.
That's obviously a very long term kind of idea, but one that could be
powerful for entering highly structured data (like forms and database
models).  There are a limited set of options at every stage, so if you
could define what those options are, an easy way of choosing them
(such as drop down lists) could be presented to the user.


More information about the textmate mailing list