Snippets

Snippets are ways of making writing new clauses more efficient and/or more readable. They are re-usable pieces of text that can either be used inside one clause (internal snippets) or as part of all clauses (external snippets).

Snippets work similar to variables in mathematics or programming languages. They are referenced by a name and represent a piece of text.

Internal snippets

Internal snippets are pieces of text that can be used multiple times inside the same clause. They will not be available outside the clause where they are defined.

Internal snippets are defined at the bottom of a clause as follows: NAME-SNIPPET = content snippet. Insert the name by which you want to refer to the snippet in all caps, e.g. NAME-SNIPPET. Then, after the equals symbol (=), insert the text you want to be inserted in all places where the snippet is referenced.

Referring to an internal snippet (i.e. showing ClauseBase where the snippet text should be placed) is done by taking the name of the snippet and adding an “at” symbol @. For example:

1. This is @SNIPPET.

SNIPPET = a snippet, which will be replaced by the text defined at the bottom of the clause grammar

Will result in the following:

Snippets may contain all types of text, datafields or conditions. They can even refer to other (internal or external) snippets, making multi-tiered snippets possible.

Always leave at least one blank line between each definition of an internal snippet.

External snippets

External snippets are similar to internal snippets. They are, however, defined and referenced differently.

Defining an external snippet

Because an external snippet should be made available to all clauses inside your library, it should be defined outside a normal clause. It is defined by creating a normal clause which will be used as a kind of special purpose vehicle.

Naming an external snippet follows the same rules as the naming of a concept. The file name of the clause that will serve as an external snippet may, e.g., not contain any spaces as that would make referring to the external snippet impossible (see below). It is not necessary to use all caps when naming an external snippet.

Enter the text for your snippet as the clause’s content body.

Referring to an external snippet

While internal snippets are referenced by simply adding a @-prefix, external snippets are referenced differently. After the @, a hashtag has to be added as well: @#. For example: @#external-snippet.

Purposes

Efficiency and consistency

Snippets can make writing clauses more efficient and consistent. Using snippets, you can easily create a piece of text that is used in many spots at once. This also saves time when that piece of text must be changed or updated: just change the snippet and all places where that snippet is referenced will automatically incorporate that change (which is much the same way a library clause functions).

Readability

A snippet can also make reading clause grammar more easy. For example, conditional text may become very complex if multiple conditions have to be evaluated at the same time. Long/complex grammar may make the structure of the clause grammar difficult to read. Replacing the most complex bits of grammar with snippets will improve readability.

Example

The following grammar is rather difficult to read:

1. <#Seller> shall use <its: seller> best efforts to satisfy or procure the satisfaction of #conditions-precedent in {AND | {"cp-change-of-control" in #conditions-precedent^!seller-responsibility: §cp-change-of-control} | {"cp-competition-clearance" in #conditions-precedent^seller-responsibility: §cp-competition-clearance} | {"cp-financing" in #conditions-precedent^seller-responsibility: §cp-financing} | {"cp-security-release" in #conditions-precedent^seller-responsibility: §cp-security-release} | {"cp-waiver-first-refusal" in #conditions-precedent^seller-responsibility: §cp-waiver-first-refusal}} as soon as [reasonably] possible.

2. <#Purchaser> shall use <its: purchaser> best efforts to satisfy or procure the satisfaction of #conditions-precedent in {AND | {"cp-change-of-control" in #conditions-precedent^!purchaser-responsibility: §cp-change-of-control} | {"cp-competition-clearance" in #conditions-precedent^purchaser-responsibility: §cp-competition-clearance} | {"cp-financing" in #conditions-precedent^purchaser-responsibility: §cp-financing} | {"cp-security-release" in #conditions-precedent^purchaser-responsibility: §cp-security-release} | {"cp-waiver-first-refusal" in #conditions-precedent^purchaser-responsibility: §cp-waiver-first-refusal}} as soon as [reasonably] possible.

3. Each @singular(#-parties) shall notify the other @singular(#-parties) as soon as it becomes aware that @singular(#?conditions-precedent) has been satisfied.

Using internal snippets, we can improve this grammar:

1. <#Seller> shall use <its: seller> best efforts to satisfy or procure the satisfaction of #conditions-precedent in @CPS-SELLER as soon as [reasonably] possible.

2. <#Purchaser> shall use <its: purchaser> best efforts to satisfy or procure the satisfaction of #conditions-precedent in @CPS-PURCHASER as soon as [reasonably] possible.

3. Each @singular(#-parties) shall notify the other @singular(#-parties) as soon as it becomes aware that @singular(#?conditions-precedent) has been satisfied.

CPS-SELLER = {AND | {"cp-change-of-control" in #conditions-precedent^!seller-responsibility: §cp-change-of-control} | {"cp-competition-clearance" in #conditions-precedent^seller-responsibility: §cp-competition-clearance} | {"cp-financing" in #conditions-precedent^seller-responsibility: §cp-financing} | {"cp-security-release" in #conditions-precedent^seller-responsibility: §cp-security-release} | {"cp-waiver-first-refusal" in #conditions-precedent^seller-responsibility: §cp-waiver-first-refusal}}

CPS-PURCHASER = {AND | {"cp-change-of-control" in #conditions-precedent^!purchaser-responsibility: §cp-change-of-control} | {"cp-competition-clearance" in #conditions-precedent^purchaser-responsibility: §cp-competition-clearance} | {"cp-financing" in #conditions-precedent^purchaser-responsibility: §cp-financing} | {"cp-security-release" in #conditions-precedent^purchaser-responsibility: §cp-security-release} | {"cp-waiver-first-refusal" in #conditions-precedent^purchaser-responsibility: §cp-waiver-first-refusal}}

Alternatively, using external snippets, we would have the following three clauses:

1. <#Seller> shall use <its: seller> best efforts to satisfy or procure the satisfaction of #conditions-precedent in @#cps-seller as soon as [reasonably] possible.

2. <#Purchaser> shall use <its: purchaser> best efforts to satisfy or procure the satisfaction of #conditions-precedent in @#cps-purchaser as soon as [reasonably] possible.

3. Each @singular(#-parties) shall notify the other @singular(#-parties) as soon as it becomes aware that @singular(#?conditions-precedent) has been satisfied.

A snippet called cps-seller:

{AND | {"cp-change-of-control" in #conditions-precedent^!seller-responsibility: §cp-change-of-control} | {"cp-competition-clearance" in #conditions-precedent^seller-responsibility: §cp-competition-clearance} | {"cp-financing" in #conditions-precedent^seller-responsibility: §cp-financing} | {"cp-security-release" in #conditions-precedent^seller-responsibility: §cp-security-release} | {"cp-waiver-first-refusal" in #conditions-precedent^seller-responsibility: §cp-waiver-first-refusal}}

And a snippet called cps-purchaser:

{AND | {"cp-change-of-control" in #conditions-precedent^!purchaser-responsibility: §cp-change-of-control} | {"cp-competition-clearance" in #conditions-precedent^purchaser-responsibility: §cp-competition-clearance} | {"cp-financing" in #conditions-precedent^purchaser-responsibility: §cp-financing} | {"cp-security-release" in #conditions-precedent^purchaser-responsibility: §cp-security-release} | {"cp-waiver-first-refusal" in #conditions-precedent^purchaser-responsibility: §cp-waiver-first-refusal}}

These final two external snippets can be used in other clauses as well by using the references @#cps-seller and @#cps-purchaser.

Using snippets to reuse values

While most snippets will contain text, it is also possible to use snippets as containers for data-values and calculations. For example:

1. Buyer will pay an amount equal to @INTEREST before 1st January. If this payment is not successfully performed, it will be automatically increased to {@INTEREST * 2}.

@INTEREST = (100 + #contract^minimum-interest-base + (#contract^value * 0.05))

Instead of repeating the fairly complex interest-calculation all over the contract, you can store it in an (internal or external) snippet and reuse it.

Note: When storing a value or calculation in an external snippet, you should wrap it in curly braces { ... } to avoid that the contents of the snippet would be treated as clause text. (As explained in Mixing Data Types, clause text cannot be used to perform calculations.)

The underlying reason is that ClauseBase will always try first to treat internal snippets as a calculation or condition. Only when that fails, it will treat the internal snippet as mere text. Accordingly, in an internal snippet, it is not necessary to wrap a value or calculation in curly braces.

The reverse is true for the main body of a clause, where ClauseBase will treat contents as text, except when put between curly brackets.

Using (internal) snippets to reuse conditions

Internal snippets cannot only store values and expressions, but also conditions. For example, instead of repeating the same logic over and over again:

1. {#contract^value > 6000 EUR AND #contract^jurisdiction = "dutch": For high-value contracts under Dutch law, #Seller shall provide the following exception ...}

2. If #Buyer purchases more than {#contract^value > 6000 EUR AND #contract^jurisdiction = "dutch": 300 | else: 600} items, then ...

…. you can store the condition in an internal snippet, and reuse it everywhere, thereby increasing readability and consistency:

1. {@HIGH-VALUE-DUTCH: For high-value contracts under Dutch law, #Seller shall provide the following exception ...}

2. If #Buyer purchases more than {@HIGH-VALUE-DUTCH: 300 | else: 600} items, then ...

HIGH-VALUE-DUTCH = #contract^value > 6000 EUR AND #contract^jurisdiction = "dutch"
It is not possible to use external snippets for storing conditions.

Using snippets to perform if/then/else switches within another calculation

Sometimes it is useful to switch between values in the middle of a calculation.

For example, assume that in a certain contract the price of the tomatoes that are sold, depends on the country, the weather and the volume:

price = base-price * country-factor * weather-factor * volume

If, for example, there are 4 possible countries (NL / FR / DE / UK) and 3 possible weather-conditions (dry / humid / stormy), you would end up with a huge number of if/then/else parts:

The agreed price is equal to: 
{ #country^name = "nl" AND #weather^condition = "dry": #contract^base-price * 1.1 * 2.1 * #contract^volume
| #country^name = "nl" AND #weather^condition = "humid": #contract^base-price * 1.1 * 2.3 * #contract^volume
| #country^name = "nl" AND #weather^condition = "stormy": #contract^base-price * 1.1 * 2.5 * #contract^volume
| #country^name = "fr" AND #weather^condition = "dry": #contract^base-price * 1.5 * 2.1 * #contract^volume
| #country^name = "fr" AND #weather^condition = "humid": #contract^base-price * 1.5 * 2.3 * #contract^volume
| #country^name = "fr" AND #weather^condition = "stormy": #contract^base-price * 1.5 * 2.5 * #contract^volume
| and so on for the other two countries}

In such situations, it is much cleaner to use the following:

The agreed price is equal to: 
{ #contract^base-price * @COUNTRY * @WEATHER * #contract^volume }

COUNTRY = {#country^name = "nl": {1.1} | "fr": {1.5} | "de": {1.8} | "uk": {1.2}}

WEATHER = {#weather^condition = "dry": {2.1} | "humid": {2.3} | "stormy": {2.4}}
Note that you have to wrap the numbers within curly braces, otherwise they would be treated as text (see the Mixing Data Types page for an explanation), so that an error would be produced.
Another possibility is to use the @switch special function. However, when the amount of cases gets high, it is probably cleaner to split calculations in several parts, using the if/then/else constructs above.
Was this article helpful?
Dislike
Clause structure
Introduction to clauses