Home  /  RSS  /  RSS Comments  /  RSS for Templates  /  Enter

Posts in category ‘Templates’.

New templates in trunk

Saturday, October 18, 2008, by artyom ; Posted in: Progress, Templates; 0 comments

New templates branch finally merged to trunk.

This blog is now running on new templates system. Please, inform me in case of any problems.

Thanks.

Preparing to Beta 2...

Thursday, October 16, 2008, by artyom ; Posted in: Progress, Templates, Cache; 10 comments

What expected in the next beta version:

  1. Now CppCMS is really ready for serving high load sides, thanks to new distributed cache module based on Boost.Asio.

    Several CppCMS processes running on different computers can share same cache distributed over several TCP/IP cache servers.

  2. Staticly typed template system that fully integrated with the framework that allows:
    • "Django style" template inheritance.
    • Powerful extendsions abilities using C++ code directly.
    • Static compilation with generated templates code or loading templates as external shared objects.
    • Creates a potential for future "forms/widgets" integration.
  3. Various bugfixes and code cleanup.

Possibly included: form validation and generation modules.

to be Continued...

Thoughts about template system

Tuesday, August 5, 2008, by artyom ; Posted in: Templates, Framework; 5 comments

After looking how ASP.Net and J2EE work I thought a lot about current template system.

Today, CppCMS template system is dynamic typed. For example in order to render template:

<% template mycontent %>
<p>You have <% number %> of <% something %></p>
<% end %>

I write something like that (not correct code but idea):

map<boost::any> content; 

content["something"]=string("orange");‎
content["number"]=10;

template.render(content,output); 

The template is compiled to bytecode and than interpreted in rendering engine. If variable title required it checks its type and renders its content.

Another possible approach it to make is statically typed :

So, I create a view interface for template:

struct mycontent: public content {
  string something;
  int number;
};

And then the above template is compiled to following C++ code:

void mycontent::render()
{
  cout<<"<p>You have "<<number<<" of "<<escape(something)<<"</p>\n";
} 

That is compiled to shared object that I can load dynamically. And render template as following:

auto_ptr<my_content> content(template.get("my_content"));
content->number=10;
content->something="orange";

content->render(output); 
more...

Thread Safe Implementation of GNU gettext

Saturday, April 26, 2008, by artyom ; Posted in: Progress, Templates, Unicode and Localization; 0 comments

There is widely available software internationalization tool called GNU gettext. Is is used as base for almost all FOSS software tools. It has binding to almost every language and supports many platforms including Win32.

How does it works? In any place you need to display a string that may potentially show in other language then English you just write:

printf(gettext("Hello World\n"));

And you get the required translation for this string (if available).

In 99% of cases this is good enough. However, as you can see, there is no parameter "target language". It is defined for entry application.

What happends if you need to display this string in different languages? You need to switch locale, and this operation is not thread safe. In most of cases you do not need to do this, because almost all applications will "talk" in single language that user had asked. However this is not the case of web based applications.

Certain web application allow you to display content in several languages: think of government site that should display information in three languages: Hebrew, Arabic and English. So you may need to define the translation per each session you open or use.

So, if you write a multithreaded FastCGI application that supports different languages is signle instance you can't use gettext.

more...

The Roadmap to The First Beta Version of CppCMS

Wednesday, April 16, 2008, by artyom ; Posted in: Progress, Storage, Templates, Framework, Cache; 4 comments

After quite a long period of development I had decided to get prepared to first public beta release of CppCMS.

The major components of this blog and the framework I want to introduce in first beta are following:

There are lots of work to do, but CppCMS now looks much mature then before.

more...

next page

Pages

Categories