Re: [Cppcms-users] rendering parts of a template
Brought to you by:
artyom-beilis
From: Artyom <art...@ya...> - 2011-02-05 10:42:44
|
>i would like to ask if there is a clean way to >* render only part(s) of a template, for example determined by tag ><% template foo() %>...<% end template %> If you have a foo template in view bar that uses bar_content You can create a small and simple view like <% view foo_caller uses bar_content extends bar %> <% template render() %><% include foo() %><% end %> <% end view %> And then call render("foo_caller",some_content) >* encapsulate them in json object and send it to browser > background> i would like to (optionally) enable ajax support for this >scenario: > > send form, process it, show page with form and changed parts of the page >again. > > with ajax i would like to asynchronously send form, process, send back html > "snippets" & then redraw only corresponding parts of the page. You can use render(std::string template_name,std::ostream &,base_content &) See: http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1application.html#58581e959b24512b24bd1ba8329fefb5 But you should remember to use correct locale in the stream std::ostringstream ss; ss.imbue(context().locale()); // important for translations, filters, formatting render("foo_caller",ss,foo_content); my_json_object["html"]=ss.str(); > >second question> do you have favourite libs for generating captcha You can use image magic to create ones, I've written one once. Feel free to use it: http://art-blog.no-ip.info/files/captcha.zip Note it is quite hard captcha to use for "human being" It is not so fast even when you reuse the same captcha generating object that uses letters cache (5ms for at Athlon XP 3000) > or sending emails from cppcms? > system("sendmail ... " ) ? or other command line tool. > > > >pavel. Artyom |