Command Reference CIB jsMerge

Syntax Basics

Mixed Script and Content Fields

The following examples show how script fields and content fields can be combined to a useful structure:

{# if(ref(“firstname“)== “Bob“) {Hello Bob!} else {‘Hello everybody!}  } 

Depending on the variable “firstname” either the text of the first content field “Hello Bob!” or the text of the second content field “Hello everybody” is written to the resulting document.

The next example uses a switch statement to output 3 different, alternative text snippets depending on the variable “firstname”.

{#switch(ref(“firstname“)) {
case “Bob“: {Hello Bob!} break; case “Alice” {Hello Alice!} break;
default: {Hello everybody!}  
}}