[Vala] Valum and ctpl update



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("""
        <p> hello {foo} </p>
        <p> hello {bar} </p>
    """);

    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<string, Value?> 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]