.. include:: ../../../Includes.txt .. _convertingXmlTemplatesToFluidTemplates: =========================================== Converting XML Templates to Fluid Templates =========================================== Converting Basic Templates ========================== The conversion process is quite simple. - Prefix all tags with `c:`. - References are written as `tag__id` instead of `tag#id`. This change is because the character # is not permitted in Fluid variable names. - To get the value associated with a reference, use the conventional Fluid accessor for variables, i.e. `{tag__id}`. .. note:: Parameters in chart tags (data, options, width, and height), can be values or references. - If they are values, they must be specified directly, for example width="600", or obtained using an accessor. For example {data__width} can be used if is called before the chart tag. - As references, the related tags can be defined before or inside the chart tag. Therefore, the best practice for `data` and `options` is to always use references. See :ref:`Designing Templates from Examples <_designingTemplatesFromExamples>`. Converting Advanced XML Templates to Fluid Templates ==================================================== Advanced templates are designed to display multiple sets of data on the same chart. Between one and nine sets of data can be displayed on the same chart. As colour label sets and data sets are built iteratively, a special `` was introduced in the XML Parser. This leads to complex statements and poor readability. In Fluid-based templates, however, conventional Fluid syntax and viewHelpers can be used. Therefore, using the `` viewHelper greatly improves readability. Let us illustrate this point with part of the `LineChartsAdvanced.xml` template. The `` tags in the following excerpt contain data with IDs `data` and `labels`, as well as intermediate data tags with IDs `initData` and `initLabels`, which are used to build them. The Fluid-based version uses simpler code thanks to the `` viewHelper. .. tabs:: .. tab:: Fluid Parser .. code-block:: xml .. tab:: XML Parser .. code-block:: xml Similarly, the following excerpt shows how data with the ID `dataSets` were set, using markers with IDs `setId` and `labelSetId`. They are needed to generate new markers with IDs `labelSet0`, `labelSet1`... and the items with IDs 0, 1... for `dataSets`. Once again, Fluid syntax makes it simpler because accessors can be used in accessors. For example, `{data__lowIntensityColors.{key}}` returns the value at the position given by `key` in the data with the ID `lowIntensityColors`. .. tabs:: .. tab:: Fluid Parser .. code-block:: xml #fff .. tab:: XML Parser .. code-block:: xml #fff