Re: [Vala] Valum and ctpl update

2011-12-11 Thread Antono Vasiljev

On 12/11/2011 07:02 PM, Denis Kuzmenok wrote:


Think   of   looking   for  modify  date of templates and save them to
exclude  repeated  template parsing. That would speed up template work
for a little bit :)


As for me template file should be accessed only during template engine 
initialization. All other checks not needed at all. In case of CTPL
template should be loaded into memory and lexed only one time and only 
at startup.


___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] Valum and ctpl update

2011-12-11 Thread Antono Vasiljev

Hello, All.

I've just pushed first templating engine for Valum[0] based on
ctpl.vapi provided by Matias De la Puente. Meanwhile Colomban Wendling
started work on native GObject introspection support in ctpl[1].

As we discussed Valum will be able to support multiple rendering engines
at the same time, so i implemented Valum.View.IView interface[2]. Not 
sure it will fit all cases, so if you find some flaws feel free to 
comment the source on github. I hope we will see CTPP2 and Clearsierver

integration soon :)

It's small example how you can use rendering engine:

var app = new Valum.App();
var tpl = new Valum.View.Tpl();

tpl.from_string("""
 hello {foo} 
 hello {bar} 
""");

app.get("ctpl/:foo/:bar", (req, res) => {
   res.vars["foo"] = req.params["foo"];
   res.vars["bar"] = req.params["bar"];
   res.append(tpl.render(res.vars));
});

res.vars is basically HashMap so you can
assign any Value there. However it will only render strings
in current implementation[3]. To implement rest of sotry
I need some way to reflect type of (G)Value. Not sure how to
do it. Suggestions and help welcome :)

I going to implement render method inside Response object
so we will be able just call app.render() to get rendered template
(and maybe implicity appended to response body). Probaby
Request.params should be also available via Response.vars
collection probably via GBind.


Also i've added some cool ideas to TODO[4].

Thats all for now :)


[0]: http://github.com/antono/valum
[1]: 
http://git.tuxfamily.org/ctpl/ctpl/?p=gitroot/ctpl/ctpl.git;a=shortlog;h=refs/heads/gir-support
[2]: 
https://github.com/antono/valum/commit/e1a1a3999265c722b76e03e22e6feb90584fc9b5#diff-2

[3]: https://github.com/antono/valum/blob/master/valum/view/tpl.vala#L32
[4]: https://github.com/antono/valum/blob/master/TODO.md


--
http://antono.info/
http://github.com/antono
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list