GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing jinja2cpp.github.io — Basic Features The simplest caseLet’s say you have the following enum: And you want to automatically produce string-to-enum and enum-to-string convertor. Like this: Of course, you can write this producer like this. It’s too complicated to write ‘from scratch’. But there is a better and simpler way. Firstly, you should define the simple jinja2 template (in the C++ manner): This template is quite basic. Actually, this is the regular text mixed with blocks, which have special meaning. Template parts wrapped with ‘{{‘ and ‘}}’ are expressions. During the template rendering this expression will be evaluated and the result will be inserted into the final text. For instance, Template parts wrapped in ‘{%’ and ‘%}’ are “statements” or control blocks. Such statements have special meaning and different processing inside Jinja2C++ engine. For instance, Template author can define new variables via
And now, the template can be rendered: And you will get on the console the conversion function mentioned above! You can call ‘Render’ method many times, with different parameters set, from different threads simultaniously. Everything will be fine: every time you call ‘Render’ you will get the result depended only on provided params (or global settings taken from the |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |