CircleScript
CircleScript is a macro substitution language that uses [$path] syntax to reference content stored in the CMS (Content Management System.) The same syntax can also be used to reference “local definitions” or simple tags.
Content replacement and concatenation language
| Function | Description | Syntax |
|---|---|---|
| Simple header example | Create a header file and store it in the CMS under “/headers/myheader.html” and then pull that content into my mailing with the dollar-tag syntax. |
-> contents of "myheader.html" |
| $using directives | Start your content with one or more $using directives. Following the above example: |
-> contents of "myheader.html" |
| Local definitions | Make definitions at the top of your content to be available when evaluating subsequent content. |
-> Thanks for playing chess! |
| Recursion | Whenever a dollar-tag is resolved, it’s value is also evaluated. |
-> Hello chief! |
| CMF data files | There are special Content Management Files (.cmf) generally referred to as “data files” that can be used to define multiple (even thousands) of definitions within the same file. From CircleScript's perspective, a CMF file is just like a directory full of individual definitions. |
-> Because of the $using directive, when the system tries to resolve [$offers], it will first look in “/data/mydata.cmf”, if it exists. |
| Templates | You can define an html with all of the content that remains the same across mailings. This contains dollar-tag references that template must resolve for each individual mailing (or each individual recip.) You then upload a data (.cmf) file with all the specific definitions. This data file is updated before each mailing. |
|
| Defaults - Coalescence | There are two simple mechanisms for providing defaults: Coalescence and Guard. These require a local definition. Coalescence operations can be chained. |
-> If [-_firstname-] is not blank, it will be used. If it is blank, "Friend" will be used instead. |
| Defaults - Guard | There are two simple mechanisms for providing defaults: Coalescence and Guard. These require a local definition. |
-> If [-level-] is not blank (e.g. 7), [$level_message] will resolve to "You are at level 7!". If [-level-] is blank, $level_message] will also be blank. |
| Logic - AND |
Coalescence and guard syntax can be used to implement simple AND logic. Use BLANK to represent false and ANYTHING ELSE to represent true. Note: any non-blank value ("1", "yes", "42") will represent TRUE. A missing tag will also be evaluated to within the context of a coalescence or guard expression. |
-> 1 and 2 : yes 2 and 3 : no |
| Logic - OR |
Coalescence and guard syntax can be used to implement simple OR logic. Use BLANK to represent false and ANYTHING ELSE to represent true. Note: any non-blank value ("1", "yes", "42") will represent TRUE. A missing tag will also be evaluated to within the context of a coalescence or guard expression. |
-> 1 or 2 : yes 2 or 3 : no |
| Iteration ($each directive) | Use the $each directive to repeat a block of code multiple times. |
-> Repeat me!Repeat me!Repeat me! |
| Iterator in Path ($each directive) | Use the $each directive to insert iteration in paths. |
-> [$content_1][$content_2][$content_3] |
| Implicit Path Iteration ($each directive) |
Use the $each directive to insert iteration in paths. Note: [$content_*] becomes shorthand for [$content_[$i]] |
-> [$content_1][$content_2][$content_3] |
| Qualifying the Each Block ($each directive) |
-> <p>[$content_1]</p><p>[$content_2]</p>... until [$content_N] is blank or missing |
|
| Iteration in a Sub Context ($each directive) | Loop through a block of content that's in the middle of some other content, put the content that's to be repeated into a sub-context, and makethe first line an $each directive. |
-> <table> <tr><td>[$c1_1]</td><td>[$c1_2]</td>...</tr> <tr><td>[$c2_1]</td><td>[$c2_2]</td>...</tr> ... </table> |
| Short Circuiting ($each directive) | The $each directive will stop once it's block produces no output. For example, if only $content_1 is defined. |
-> [$content_1] |
| Short Circuiting ($each directive with $guard) | The $each directive will stop once it's block produces no output. For more complex blocks, use the ?[$guard]: syntax. |
-> <p>[$content_1]</p> |
CircleScript functions
Note: CircleScript functions follow the format [$functionName(args)]
| Function | Description | Syntax |
|---|---|---|
| base64 | Base-64 encode a string. This is useful for obfuscating link parameters. | |
| contains |
Write alternate content based on whether one string value contains another. If [on_equal] is not specified, "true" will be used. If [otherwise] is not specified, "" (blank) will be used. |
|
| currentdate | Write the current date, using the given format string, or 'MM/dd/yyyy' if not specified. | |
| dynamic_title_web_fetch |
Fetch content from a given URL and extract a title. If the fetched content contains <title> tags, then their contents will be extracted, otherwise the entire contents will be written. URL must start with "http://" or "https://" |
|
| ends_with |
Write alternate content based on whether one string value ends with another. If [on_equal] is not specified, "true" will be used. If [otherwise] is not specified, "" (blank) will be used. |
|
| escapehtml | Escape HTML characters in a string. |
|
| formatdate | Write the given date, using the given format string, or 'MM/dd/yyyy' if not specified. | |
| greater_than |
Write alternate content based on whether one integer is greater than another. If [on_equal] is not specified, "true" will be used. If [otherwise] is not specified, "" (blank) will be used. |
|
| if_equal |
Write alternate content based on string equality. If [on_equal] is not specified, "true" will be used. If [otherwise] is not specified, "" (blank) will be used. |
|
| less_than |
Write alternate content based on whether one integer is less than another. If [on_equal] is not specified, "true" will be used. If [otherwise] is not specified, "" (blank) will be used. |
|
| money |
Write the given decimal value using the default or specified formatting. To round to the nearest dollar, provide the format "%1$,.0f" as the second argument. |
|
| multiply |
Multiply the given arguments. Works for integer and decimal values. Returns a blank if any of the arguments are blank or are not valid integers. |
|
| starts_with |
Write alternate content based on whether one string value starts with another. If [on_equal] is not specified, "true" will be used. If [otherwise] is not specified, "" (blank) will be used. |
|
| title | Title Case a string. If the string has multiple words, the first letter of each word is capitalized. | |
| unescapehtml | Un-escape HTML characters in a string. |
|
| urlencode | URL Encode a string. This is useful for encoding link parameters that may contain special characters. | |
| urlencode2 | URL Encode a string twice. Same as URL encode, except that the string is encoded twice. | |