Snippets - ScrewTurn Wiki

Since version 2.0, ScrewTurn Wiki supports Snippets. This page will help you understand how to use them.


1 - What is a Snippet?

A Snippet is a typically small piece of text that can be included anywhere in the Wiki. A Snippet can contain WikiMarkup, XHTML and plain-text. Snippets can be created, deleted and modified only by the Administrators, using the dedicated panel in the administration page. Every Snippet must have a unique name.

2 - Using Snippets

A snippet can be inserted by simply using the following syntax:

{s:SnippetName}

where SnippetName is the name of the snippet you want to insert (case insensitive).

You can add a snippet in a Page or in any of the "meta" files (Sidebar, Header, etc.). Snippets are "resolved" recursively, so you can insert a Snippet into another. If you insert a non-existent Snippet, you will get a red warning in the Page stating "FORMATTER ERROR (Snippet Not Found)."

2.1 - Example

To produce a reusable Draft snippet like this:

This page is a Draft. Its content is not complete and might contain errors.

you should paste the following code into a new Snippet named Draft in the administration interface (see next section):

<div 
    style="border-top: solid 2px #FED626;  
        border-bottom: solid 2px #FED626; 
        padding: 4px 4px 4px 36px; 
        vertical-align: middle; 
        background-color: #FFF7C0; 
        background-image: url({UP}Alert.png); 
        background-repeat: no-repeat; 
        background-position: 10px center;">
    This page is a ''Draft'', its content is 
    not complete and might contain errors.
</div>

You then should upload the Alert.png file into your Wiki using the File Management page.

2.2 - Toolbar

You can also insert a Snippet using the handy "Insert a Snippet" button of the editing Toolbar, which displays a menu containing all the available Snippets.

3 - Snippets Management

Snippets Management

Snippets Management

The Snippets tab of the administration interface allows you to create, edit and delete snippets. The list displays the existing Snippets and their Provider.

3.1 - Creating a new Snippet

To create a new Snippet, click on the New button and insert the Snippet name and content. You can also select the Provider to use for the new Snippet. When you are finished, click on the Save Snippet button.

3.2 - Deleting a Snippet

To delete a Snippet, select it in the list and then click on the Delete button. You will be asked to confirm the operation.

3.3 - Modifying a Snippet

You can edit the content of a Snippet (but not the Name). To do so, select it in the list and then click on the Edit button. Modify the content, and then click on the Save Snippet button.

4 - Parameterized Snippets

Since version 2.0.25, Snippets can be parameterized. A parameterized Snippet reads something like this:

This is a ?1? Snippet. Is it cool? ?2?

A mark like ?n? represent the placeholder for the nth snippet parameter, which will be replaced at runtime with the specified value. In order to specify the value, add a Snippet with the following markup (assume the Snippet reported above is called MySnip):

{s:MySnip|parameterized|Yes, it is!}

The output will be:

This is a parameterized Snippet. Is it cool? Yes, it is!

As you see, parameterized is the first parameter, Yes, it is! is the second. You can specify as many parameters as you need, and they can also be blank, but they cannot contain CRLF characters (in other words, you cannot start a new line in the middle of a Snippet declaration). A parameter cannot contain pipes; if you need them, just use the corresponding HTML escape sequence &#124;.