Re: [Cppcms-users] Local variables in template
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2015-01-20 13:10:44
|
No, currently there is no support of such a functionality.The local variables are recognized withing <% foreach %> block and <% template %>... It is actually not a bad idea to add some kind of "local" block that would define potential local variables that can be recognized by the templates compiler automatically. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ From: Tolga HOŞGÖR <fas...@gm...> To: cpp...@li... Sent: Monday, January 19, 2015 10:13 PM Subject: Re: [Cppcms-users] Local variables in template By the way, I know I can use <% c++ ... %> by the way but then I have to manually add the escape function. I am asking if there is another, better way of doing it. On Mon Jan 19 2015 at 10:02:11 PM Tolga HOŞGÖR <fas...@gm...> wrote: Hello, First of all thanks for this great project. It works flawlessly and it is well designed. I looked through the documentation but I could not find anything about declaring and using local variables in templates. My exact use case is a boost::optional variable used as: <div style="(<% if (const auto var = object->test()) %>property: <%= *var %>;<% end %>)"></div> where object->test() returns a boost::optional<std::string>. The problem is that inside the if statement, *var is automatically replaced with *content.var. Is there a way to prevent this? What is the correct way of this kind of usage? Thanks. ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |