Skip to main content
MindTouch Success Center

Learn about DekiScript (TCS)

Overview

DekiScript is a scripting language that is available in MindTouch to add dynamic elements to your knowledge.  DekiScript has over 100 built-in functions for accessing and manipulating data.  With DekiScript you can embed content from another article, add conditions and generate personalized content for the current user.  

Hello World

Here is the "Hello World" equivalent in DekiScript.  Just open any page and type in the following text:

{{ 'Hello World' }}

The double curly braces indicate to MindTouch that contents are DekiScript code.

The output is as expected: Hello World

   

Since DekiScript can be embedded side-by-side with regular content in a page, it is trivial to create dynamic content. The following code shows a personalized welcome message:

Hi {{ User.Name }}, today is {{ Date.DayName(Date.Now) }}.

Which produces this output: Hi Anonymous, today is Saturday.

   

If you're not logged in, your name will appear as Anonymous, wich isn't a great way to greet someone.  Let's fix that.  The following code uses the ?: operator to check if the user is known or not and show the appropriate greeting.

Hi {{ User.Anonymous ? 'stranger' : User.Name }}, today is {{ Date.DayName(Date.Now) }}.

Which produces this output: Hi stranger, today is Saturday.

Using a DekiScript Style Block

Not all DekiScript has to be wrapped in double curly braces.  In some cases it might more more sense to separate and highlight your DekiScript code.  You can use a DekiScript block to help organize your code and make it easier for other users to read.  Follow the instructions below:

  1. In the page editor select Styles > DekiScript
  2. Add your DekiScript to the red DekiScript box
  3. Don't use double curly braces, they will produce an error inside a DekiScript block
  4. Use // to add inline comments
  5. Click Save to execute your DekiScript code

Using Variables

The following example shows how to set a variable, print a variable and how to reset an existing variable.

{{
var output = "Hello World";		        // Set the output variable
output;					                // Print the output

let output = "Hello Universe";  	    // Reset the ouput variable
output; 				                // Print the output
}}

Inserting HTML In a DekiScript Block

When inserting HTML into a DekiScript block, you'll need to ensure any strings are surrounded by single quotes so that they are not rendered as DekiScript calls:

<a href='https://success.mindtouch.com'> 'This text must be surrounded in quotes to be rendered as a link!' </a>

In this case, you could optionally store the URL as a variable. When referencing a variable in the HTML tags, surround it with parentheses to ensure it is rendered properly:

var linkURL = 'https://success.mindtouch.com';

<a href=(linkURL) target='_blank'> 'This text must be surrounded in quotes to be rendered as a link!' </a>

If you need to add a text string to a DekiScript block that preceeds HTML on the same line, separate the string with a semi-colon:

var linkURL = 'https://success.mindtouch.com';

<p>
'This is just a string.'; <a href=(linkURL) target='_blank'> 'This text must be surrounded in quotes to be rendered as a link!' </a>
</p>

Surrounding Strings with Double Quotes

For best practices, we recommend surrounding text strings with double quotes, though in some cases you may need double quotes. For instance, if you need to include an apostrophe within a text string, you'll need to surround that text string with double quotes:

<p>
"This is John's example of a link"; <a href=(linkURL) target='_blank'> 'This text must be surrounded in quotes to be rendered as a link!' </a>
</p>

  • Was this article helpful?