<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>CppCMS Blog :: Templates</title>
	<link>http://blog.cppcms.com/</link>
	<description>A blog on CppCMS - C++ Web Development Framework</description>
	<atom:link 
		href="http://blog.cppcms.com/rss/cat/4/" 
		rel="self" type="application/rss+xml" />
	

	
	<item>
		<title>New templates in trunk</title>
		<link>http://blog.cppcms.com/post/30</link>
		<guid>http://blog.cppcms.com/post/30</guid>
		<description>
		&lt;div style=&quot;direction:ltr&quot;&gt;
		&lt;p&gt;New templates branch finally merged to trunk.&lt;/p&gt;

&lt;p&gt;This blog is now running on new templates system. Please, inform me in case of any problems.&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;
		
		&lt;/div&gt;
		</description>
	</item>
	
	<item>
		<title>Preparing to Beta 2...</title>
		<link>http://blog.cppcms.com/post/29</link>
		<guid>http://blog.cppcms.com/post/29</guid>
		<description>
		&lt;div style=&quot;direction:ltr&quot;&gt;
		&lt;p&gt;What expected in the next beta version:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Now CppCMS is really ready for serving high load sides, thanks to new distributed cache module based on Boost.Asio.&lt;/p&gt;

&lt;p&gt; Several CppCMS processes running on different computers can share same cache distributed over several TCP/IP cache servers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;Staticly typed template system that fully integrated with the framework that allows:

&lt;ul&gt;
&lt;li&gt;&quot;Django style&quot; template inheritance.&lt;/li&gt;
&lt;li&gt;Powerful extendsions abilities using C++ code directly.&lt;/li&gt;
&lt;li&gt;Static compilation with generated templates code or loading templates as external shared objects.&lt;/li&gt;
&lt;li&gt;Creates a potential for future &quot;forms/widgets&quot; integration.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Various bugfixes and code cleanup.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Possibly included: form validation and generation modules.&lt;/p&gt;

&lt;p&gt;to be Continued...&lt;/p&gt;
		
		&lt;/div&gt;
		</description>
	</item>
	
	<item>
		<title>Thoughts about template system</title>
		<link>http://blog.cppcms.com/post/26</link>
		<guid>http://blog.cppcms.com/post/26</guid>
		<description>
		&lt;div style=&quot;direction:ltr&quot;&gt;
		&lt;p&gt;After looking how ASP.Net and J2EE work I thought a lot about current template
system.&lt;/p&gt;

&lt;p&gt;Today, CppCMS template system is dynamic typed. For example in order to render
template:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;% template mycontent %&amp;gt;
&amp;lt;p&amp;gt;You have &amp;lt;% number %&amp;gt; of &amp;lt;% something %&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I write something like that (not correct code but idea):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;map&amp;lt;boost::any&amp;gt; content; 

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

template.render(content,output); 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The template is compiled to bytecode and than interpreted in rendering engine.
If variable &lt;code&gt;title&lt;/code&gt; required it checks its type and renders its content.&lt;/p&gt;

&lt;p&gt;Another possible approach it to make is statically typed :&lt;/p&gt;

&lt;p&gt;So, I create a view interface for template:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;struct mycontent: public content {
  string something;
  int number;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then the above template is compiled to following C++ code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;void mycontent::render()
{
  cout&amp;lt;&amp;lt;&quot;&amp;lt;p&amp;gt;You have &quot;&amp;lt;&amp;lt;number&amp;lt;&amp;lt;&quot; of &quot;&amp;lt;&amp;lt;escape(something)&amp;lt;&amp;lt;&quot;&amp;lt;/p&amp;gt;\n&quot;;
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That is compiled to shared object that I can load dynamically. And render
template as following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;auto_ptr&amp;lt;my_content&amp;gt; content(template.get(&quot;my_content&quot;));
content-&amp;gt;number=10;
content-&amp;gt;something=&quot;orange&quot;;

content-&amp;gt;render(output); 
&lt;/code&gt;&lt;/pre&gt;
		
		&lt;p&gt;
		&lt;a href="/post/26"&gt;more...&lt;/a&gt;
		&lt;/p&gt;
		
		&lt;/div&gt;
		</description>
	</item>
	
	<item>
		<title>Thread Safe Implementation of GNU gettext</title>
		<link>http://blog.cppcms.com/post/16</link>
		<guid>http://blog.cppcms.com/post/16</guid>
		<description>
		&lt;div style=&quot;direction:ltr&quot;&gt;
		&lt;p&gt;There is widely available software internationalization tool called &lt;a href=&quot;http://www.gnu.org/software/gettext/&quot;&gt;GNU gettext&lt;/a&gt;. Is is used as base for almost all FOSS software tools. It has binding to almost every language and supports many platforms including Win32.&lt;/p&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;printf(gettext(&quot;Hello World\n&quot;));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And you get the required translation for this string (if available).&lt;/p&gt;

&lt;p&gt;In 99% of cases this is good enough. However, as you can see, there is no parameter &quot;target language&quot;. It is defined for entry application.&lt;/p&gt;

&lt;p&gt;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 &lt;em&gt;do not&lt;/em&gt; need to do this, because almost all applications will &quot;talk&quot; in single language that user had asked. However this is not the case of web based applications.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;So, if you write a multithreaded FastCGI application that supports different languages is &lt;em&gt;signle&lt;/em&gt; instance you can&#39;t use gettext.&lt;/p&gt;
		
		&lt;p&gt;
		&lt;a href="/post/16"&gt;more...&lt;/a&gt;
		&lt;/p&gt;
		
		&lt;/div&gt;
		</description>
	</item>
	
	<item>
		<title>The Roadmap to The First Beta Version of CppCMS</title>
		<link>http://blog.cppcms.com/post/15</link>
		<guid>http://blog.cppcms.com/post/15</guid>
		<description>
		&lt;div style=&quot;direction:ltr&quot;&gt;
		&lt;p&gt;After quite a long period of development I had decided to get prepared to first public beta release of CppCMS.&lt;/p&gt;

&lt;p&gt;The major components of this blog and the framework I want to introduce in first beta are following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implementation of Django style templates inheritance, filters (done 70%)&lt;/li&gt;
&lt;li&gt;Introduce powerful cache system (done 100%)&lt;/li&gt;
&lt;li&gt;Replace &lt;a href=&quot;http://soci.sourceforge.net&quot;&gt;SOCI&lt;/a&gt; by &lt;a href=&quot;http://libdbi.sourceforge.net&quot;&gt;LibDBI&lt;/a&gt; (done 100%)&lt;/li&gt;
&lt;li&gt;Improve blog: true markdown, LaTeX equations, categories etc. (done 100%)&lt;/li&gt;
&lt;li&gt;Write Documentation (done 20%)&lt;/li&gt;
&lt;li&gt;Migrate my Hebrew blog from Word Press to CppCMS (done 100%)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;There are lots of work to do, but CppCMS now looks much mature then before.&lt;/p&gt;
		
		&lt;p&gt;
		&lt;a href="/post/15"&gt;more...&lt;/a&gt;
		&lt;/p&gt;
		
		&lt;/div&gt;
		</description>
	</item>
	
	<item>
		<title>New Templates System</title>
		<link>http://blog.cppcms.com/post/14</link>
		<guid>http://blog.cppcms.com/post/14</guid>
		<description>
		&lt;div style=&quot;direction:ltr&quot;&gt;
		&lt;p&gt;New templates system was introduces to the CppCMS framework. It is based on ideas of dynamic typed languages inside static typed C++.&lt;/p&gt;

&lt;p&gt;The original template system had several problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The each template variable was referenced by and integer key that was generated during compilation of templates.&lt;/li&gt;
&lt;li&gt;The rendering process required from the developer some kind of activity -- update content values according to requests from rendering engine.&lt;/li&gt;
&lt;li&gt;The values of the entries where limited to string, integer and boolean values.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;In any case, the design of the first template system was just unacceptable, thus new template system was build.&lt;/p&gt;

&lt;p&gt;It introduced following features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic typed variable values using boost::any. They allow assigning of any kind of objects to the variables and rendering them to the templates using custom engines.&lt;/li&gt;
&lt;li&gt;All the variables are references by their names.&lt;/li&gt;
&lt;li&gt;Content now has hierarchical structure when each variable can include list of items or callbacks that allow one step template rendering.&lt;/li&gt;
&lt;li&gt;The design of the engine is now much more modular.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Additional features I&#39;m still working on them are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Support of different filters like &quot;html escaping&quot;, &quot;urlizing&quot; etc.&lt;/li&gt;
&lt;li&gt;Support of custom filters, including filter chains.&lt;/li&gt;
&lt;li&gt;Support of localization and translation.&lt;/li&gt;
&lt;/ul&gt;

		
		&lt;p&gt;
		&lt;a href="/post/14"&gt;more...&lt;/a&gt;
		&lt;/p&gt;
		
		&lt;/div&gt;
		</description>
	</item>
	
	<item>
		<title>Next Step - Caching</title>
		<link>http://blog.cppcms.com/post/7</link>
		<guid>http://blog.cppcms.com/post/7</guid>
		<description>
		&lt;div style=&quot;direction:ltr&quot;&gt;
		&lt;p&gt;As we had seen in previous article, the &lt;a href=&quot;http://art-blog.no-ip.info/cppcms/blog/post/4&quot;&gt;benchmarks&lt;/a&gt; had shown an ability of CppCMS to produce about
630 compressed pages per second and an output of about 20Mbit/s. Is this enough?&lt;/p&gt;

&lt;p&gt;For most of cases it is... But as we had seen I want to use every cycle of the CPU as smart as I can. Even, if the model I had suggested, was able to show &quot;a prove of concept&quot; there is an important point that was missed: &quot;Why should I create same page so many times?&quot;&lt;/p&gt;

&lt;h2&gt;Caching&lt;/h2&gt;

&lt;p&gt;This is the next logical step in the development of high performance web development framework.&lt;/p&gt;

&lt;p&gt;First of all we should understand a requirements of the caching system:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Efficiency&lt;/li&gt;
&lt;li&gt;Support of &quot;dropping cache on update&quot;&lt;/li&gt;
&lt;li&gt;Support of drop the cache by timeout&lt;/li&gt;
&lt;li&gt;Work using three models: single process cache, shared cache between processes, shared over the network.&lt;/li&gt;
&lt;li&gt;Support of caching on entry page level and single view level as well&lt;/li&gt;
&lt;li&gt;Transparent storage of compressed content&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Lets describe each one of them:&lt;/p&gt;
		
		&lt;p&gt;
		&lt;a href="/post/7"&gt;more...&lt;/a&gt;
		&lt;/p&gt;
		
		&lt;/div&gt;
		</description>
	</item>
	
	<item>
		<title>Components of CppCMS</title>
		<link>http://blog.cppcms.com/post/3</link>
		<guid>http://blog.cppcms.com/post/3</guid>
		<description>
		&lt;div style=&quot;direction:ltr&quot;&gt;
		&lt;p&gt;There are several important components that CppCMS implements:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;FastCGI Application Framework&lt;/li&gt;
&lt;li&gt;Easy Berkeley DB -- Simple API to BDB&lt;/li&gt;
&lt;li&gt;Templates System&lt;/li&gt;
&lt;li&gt;Text Tools -- text to html conversion tools&lt;/li&gt;
&lt;li&gt;Nice URLs support&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;I&#39;ll describe there all these in details there&lt;/p&gt;
		
		&lt;p&gt;
		&lt;a href="/post/3"&gt;more...&lt;/a&gt;
		&lt;/p&gt;
		
		&lt;/div&gt;
		</description>
	</item>
	


</channel>
</rss>
