The rendering engine of C2 offers a simple way of accessing and styling high volumes of data with predefined functions and tools. The engine is used all over C2 and can be accessed in a programmatic way by every Developer using C2. Simply said constists functionality out of 3 Areas; 1. Data, 2. Layout and 3. User Input.

Take note that this area is still under construction and likely to change!

Minimum Required Data

The minimum amount data that is required to run a basic merging operation would be:

JSON Data Object

Important to note is that the supplied JSON doesnt need to come directly from JS, it can be supplied by any external, internal or file source.

// REQUIRED: data, structured as a json object
{"tag":"tag contents 1","url":""},
{"tag":"tag contents 2","url":""},
{"tag":"tag contents 3","url":""}


<!-- REQUIRED: html data with Tags -->
<strong class="text">{%=xtpl_static.statvar%}</strong><br />
<a href="{%=url%}">{%=tag%}</a>

Merge HTML and Data

In order to merge the JSON Data Object with the supplied HTML you'll need to create a render function. This merges all your data and returns a html string containing your data within the set HTML. The _render function accepts an addtional staticdata parameter wich can be used to add more data and not only loops. Depending on your JSON-Source you can use each key as a tag in your HTML.

A example in javascript returning the HTML could look like:

// === data: setup json =============
var renderdata = {
templatestring: '<strong class="text">{%=xtpl_static.statvar%}</strong><br /><ul>{%loop:myLoop%}<li><a href="{%=url%}">{%=tag%}</a></li>{%endloop%}</ul>',
data: [{
myLoop: [{
"tag": "tag contents 1",
"url": ""
}, {
"tag": "tag contents 2",
"url": ""
}, {
"tag": "tag contents 3",
"url": ""
staticdata: {
"statvar": "static variable"

// === render data =============
var html = _wf._render(renderdata);

// === output rendered data =============
console.log('html string', html); // as console.log()
$('body').prepend(html); // as jquery


Any field can be outputed in its simplest form: {%=<tagname>%} The output will be converted to a string using the default Javascript method.
The Whacky Framework has a lot more options and/or rendering methods that you can apply to a field, Multiple functions can be used to transform the output required to your needs.

A simple example is:

A more elaborate example could be:


Tag modifier give you the option to manipulate the output while using our tags.



The function has the following parameters:

  • <number of digits behind the seperator>
  • <separator size before the, usually thousand e.g. 3 >
  • <thousand separator character>
  • <comma separator character>

Default: The default settings can be found in the variable: _wf.i18n.number
Note: If no format was specified, the defaults from _wf.i18n are used.



The data provided can be two types:

  • POSIX number
  • ISO datetime string

Where the format parameters can be:

a predefined format string

{%=<tagname>|date:isoUtcDateTime%} or {%=createdate|date:isoDate%}

Note: If the data is invalid, an empty string will be rendered !

Any format string


Note: If no format was specified, the defaults from _wf.i18n are used.


This function has NO functions or parameters. it will automatically create a string like 1.5 MB



Those tags only apply if used inside a loop

the current record which is rendered (0 based)


total nr of data elements (in the parsed data)


this is where the html starts (opt.start) (0 based)


End item that will get rendered (opt.end) (0 based)


Any static variable that you parse through in the options


Statements & Logic

if- / else statements

If- else-statements are used to compare values of variables, check if they are set or require the basic information needed. A simple Logic Statement could be:

                        if}myTag ===
FOOBAR VAR!: {%=myTag %}
{% endif%}
                        if}myTag ===
{% else%}
{% endif%}

custom javascript functions

 {%=( alert(myTag) )%}

logic operands

is equal

                        if}myTag ==

is not equal

                        if}myTag !=

is larger than 2

                        if}myTag >=

is lower than 2

                        if}myTag <=



Fieldtype: String

The string type has a lot of functions to transform the field into the desired format: Because there are a lot of functions, you can use multiple functions.

name example note
lowercase {%=<field>|string:lowercase%}
uppercase {%=<field>|string:uppercase%}
trim {%=<field>|string:trim%}
capitalizefirstletter {%=<field>|string:capitalizefirstletter%}
strleft {%=<field>|string:strleft(4)%}
strright {%=<field>|string:strright(4)%}
substr {%=<field>|string:substr(2,4)%} "abcdefg" becomes "cdef"
truncate {%=<field>|string:truncate(10)%} which gives the first 10 characters only
striphtml {%=<field>|string:striphtml%}

This uses the function _wf._stripHtmlTags();

encodeURIComponent {%=<field>|string:encodeURIComponent%} uses the javascriptfunction: encodeURIComponent()
decodeURIComponent {%=<field>|string:decodeURIComponent%} uses the javascriptfunction: decodeURIComponent()
htmlspecialchars {%=<field>|string:htmlspecialchars%}

escapes the following characters:

  • " => &quot;
  • ' => &#039;
  • < => &lt;
  • > => &gt;
escapedblquotes {%=<field>|string:escapedblquotes%} javascript: .split('\\"').join('"').split('"').join('&quot;');
unescapedblquote {%=<field>|string:unescapedblquote%} javascript: .split('\\"').join('"');
urlescapedblquotes {%=<field>|string:urlescapedblquotes%} javascript: .split('\\"').join('"').split('"').join('%22');
jsonstring {%=<field>|string:jsonstring%} JSON.stringify(<data>);
b64_encode {%=<field>|string:b64_encode%}

javascript: _wf.calc.b64_encode(<data>);
added in version 3.7.5

b64_decode {%=<field>|string:b64_decode%}

javascript: _wf.calc.b64_decode(<data>);
added in version 3.7.5

Fieldtype: bytes