Implementing line numbering

Ben Bullock <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CAN5Y6m8BgU2BLr0PfxHbOwW8iGL=HcQGPAVK43ZjtHbPuvp__w@mail.gmail.com>
Given a template input like

int x;
[% FOR I IN (a,b,c) %]
int [% I %];
[% END %]
int y;

in a file "in.c.tmpl", I want to add line numbering to the output, so
that the output file "in.c" looks something like this:

#line 1 "in.c.tmpl"
int x;
#line 4 "in.c"
int a;
int b;
int c;
#line 5 "in.c.tmpl"
int y;

I have been reading the template toolkit documentation such as

http://template-toolkit.org/docs/manual/Internals.html

but cannot see exactly what kinds of steps I would need to take to
implement something like this. Can anyone point me in the right
direction?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.