Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi,

I just could not resist not to try myself Smile 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 Smile 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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IntStr function returns an empty string
Next Topic: conversion from String to wchar_t
Goto Forum:
  


Current Time: Fri May 10 04:04:32 CEST 2024

Total time taken to generate the page: 0.02819 seconds