Warning, /frameworks/ktexttemplate/docs/internals.dox is written in an unsupported language. File is not indexed.

0001 
0002 namespace KTextTemplate
0003 {
0004 
0005 /**
0006   @page internals Internals
0007 
0008   @note This page is intended only to be informative for new contributors to %KTextTemplate or people who are really interested in this kind of thing. These are implementation details and are likely to change without notice.
0009 
0010   @section how_works How KTextTemplate works.
0011 
0012   A template string is first tokenized by the Lexer class. The result is a list of tokens with content which can be of type <tt>TextToken</tt>, <tt>CommentToken</tt>, <tt>VariableToken</tt> or <tt>TagToken</tt>.
0013 
0014   The tokens are further processed by the Parser class. The Parser generates nodes from the token stream. For a <tt>TextToken</tt> it generates a <tt>TextNode</tt>, for a <tt>CommentToken</tt> it generates nothing, for a <tt>VariableToken</tt> it generates a <tt>VariableNode</tt>, and for a <tt>TagToken</tt> it generates another type of Node determined by available plugins. Some plugins are built in, and others may be loaded by the template itself using the @gr_tag{load} tag, or preloaded by the application developer.
0015 
0016   The plugin uses the Abstract Factory Pattern. It returns a list of concrete factories, one for each tag handled by that plugin. The factories have a <tt>getNode</tt> method which accepts the tag content and the active parser as an argument and returns a concrete Node. The <tt>getNode</tt> method may advance the parser in the case of begin/end tags etc. When the parser is finished, it has created a tree of nodes, which is essentially a Template object.
0017 
0018   A Template is rendered with a Context object. During rendering, each node in the template has its <tt>render</tt> method called with the Context. The Node may contain different sub-trees, one of which is rendered, as is the case for <tt>IfNode</tt>, or it might contain a single sub-tree which is rendered multiple times, as in the case of <tt>ForNode</tt>, etc. The rendering outputs a string, which is the rendered output of the Template for a particular Context. A single Template may be rendered multiple times with mutliple different Contexts.
0019 
0020   Plugins can return Filter and AbstractNodeFactory instances. Filters can manipulate Variable instances in some way before rendering them to the output.
0021 
0022   Loading templates to include or extend is accomplished using the <tt>loadByName</tt> methods. The secondary template should use the same state as the initially created/loaded template, so that it uses the same template loaders, has the same plugins available by default and uses the same search directories to find additional plugins.
0023 
0024 */
0025 
0026 }
0027