Re: Multiptle lines of output

Brandon Long <[email protected]> Sat, 6 Dec 2008 21:19:08 -0800
Newsgroups gmane.text.clearsilver.general
Organization Fiction L Networks
Message-ID <20081207051908.GB32695@bl1>
On 12/06/08 Dan uttered the following other thing:
> Hi. I am trying to figure out how to display multiple lines of several
> values. I know this is basic and done all the time in CGIs, but I am
> having trouble wrapping the template around it.
> 
> I am reading data from a text file in python one line at a time. For all
> lines in the file I want to display each line as a set (list) of values
> on a form in a page. Displaying one line is easy in template, but how
> would I store multiple lines in HDF and read in a template??

I'm not sure what you're trying to do, exactly, but:

foo.hdf:
Option.1 = Foo
Option.2 = Bar
Option.3 = Baz

foo.cs:

<form action=/foo.do>
<?cs each:opt = Option ?>
<input type=radio name=<?cs var:opt ?>
<?cs /each ?>

That's storing it in HDF.  If you're loading from a regular file, it
would be something like this in python to generate the hdf:

import neo_cgi

ncgi = neo_cgi.CGI()
ncgi.parse()

lines = open("foo.dat").readlines()

lineno = 1
for line in lines:
  ncgi.hdf.setValue("Option.%d" % lineno, line)
  lineno += 1

ncgi.display("foo.cs")

Brandon
-- 
 "The end move in politics is always to pick up a gun." 
        -- R. Buckminster Fuller
                                           http://www.fiction.net/blong/