Posted Sun, 21 Oct 2012 02:21:13 GMT in reply to
Sönke Ludwig
Reply
On Sat, 20 Oct 2012 06:17:54 GMT, Sönke Ludwig wrote:
As for the actual problem ;) - I'm pretty sure that req.params["username"]
throws a RangeError there (maybe it should be req.form[]
?). If you setLogLevel(LogLevel.Debug)
, you should get a stack trace on the console that gives more certainty.
Still does not work. Here is an example:
void defaultHandler(HttpServerRequest req, HttpServerResponse res)
{
auto answ = conn.exec("select 12345");
string cell = answ[0,0].as!PGtext;
render!("test.dt", req, cell, answ)(res);
}
extends layout
block content
h3 this is a form:
form(method='get')
fieldset
legend General
label(for='username') Username:
input( type='text', name='username', value='vasya22' )
p #{cell} // done
p #{answ[0,0].as!PGtext} // error
cell variable passes to temlate parser, but answ[0,0].as!PGtext causes error:
Compiling diet template 'test.dt'...
test.dt(7): Error: undefined identifier PGtext, did you mean template text(T...)?
test.dt(7): Error: cannot resolve type for (*answ.opIndex(0LU,0LU)).as!(error)
test.dt(7): Error: template vibe.templ.diet.toString does not match any function template declaration
diet.d(912): Error: template vibe.templ.diet.toString(T) cannot deduce template function from argument types !()(error)
(answ[0,0].as!PGtext is actually a string type)
Apparently, I do not understand what types of variables supports templates parser. It would be convenient to show result of sql query in the template, but at the moment I can't.