Re: [Cppcms-users] Local variables in template
Brought to you by:
artyom-beilis
|
From: Tolga H. <fas...@gm...> - 2015-01-19 20:13:37
|
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. > |