Home » U++ Library support » U++ Core » HtmlTable class example request
Re: HtmlTable class example request [message #46114 is a reply to message #46101] |
Tue, 08 March 2016 20:32   |
|
Hi,
I just could not resist not to try myself Here is the minimal code that works:#include <Skylark/Skylark.h>
using namespace Upp;
void test() {
ValueArray va;
va.Add(1);
va.Add("Hello");
ValueMap m;
m.Add("key1", "first value");
m.Add("key2", "second value");
Renderer r;
r("MyValue", "some value")
("MyRawValue", Raw("<b>raw <u>html</u></b>"))
("MyRawValue2", "<b>another raw <u>html</u></b>")
("MyArray", va)
("MyMap", m);
DUMP(r.RenderString("Skylark02/index"));
}
CONSOLE_APP_MAIN {
StdLogSetup(LOG_FILE|LOG_COUT);
SkylarkApp dummy;
test();
}
There are two "interesting" things to notice: 1) Exactly one SkylarkApp instance must exist for the template engine to work. That is because there is a global variable used to access configuration. And 2) The code must be compiled with MT flag, because the Skylark package is (not surprisingly) written to be used with threads.
So the solution works, but it is kind of a hack It might be actually useful, if the templating code could be refactored into separate package. Applications generating HTML (that are not servers) are quite common. What do you think Mirek, is it possible?
Honza
|
|
|
Goto Forum:
Current Time: Mon May 12 03:41:38 CEST 2025
Total time taken to generate the page: 0.02536 seconds
|