[TOC] [Prev] [Next] [Bottom]



Chapter Five

Using Snippets


Snippets Basics and Operations

Snippets are named pieces of text, such as Tango meta tags, HTML tags, standard headers and footers, plain text, JavaScript, and SQL. Snippets are a good way of saving text, HTML markup, or other commands that you use frequently. You can insert snippets into most text fields and text windows throughout Tango Editor.

Tango Editor comes with a large defined set of snippets and also lets you create your own snippets.

This chapter discusses how to:

  • use snippets
  • create new snippets.
[top] [back to top]


About Snippets

Snippets allow you to quickly access text, meta tags, and HTML that you use often. You can insert snippets into an editing window by dragging them or double-clicking on a snippet when you have an HTML editing window open.

A special feature of snippets lets you surround a selection of text with HTML tags or meta tags, in addition to putting text, HTML tags, or meta tags at a particular place.

Your snippets are saved as text files inside the Tango 2000 folder inside the Preferences folder. You can edit Tango snippet files with a text editor or HTML editor, or edit them within the Snippets Workspace.

The Snippets Workspace

You manipulate and manage snippets in the Snippets Workspace.

To display the Snippets Workspace
  1. From the Windows menu, choose Workspace.
  2. Click the Snippets tab.
  3. To view the contents of a folder, expand it by clicking the disclosure triangle.

    Folders and snippets appear alphabetically.

    Snippets are grouped in five folders:

For more information, see "Column Snippets"..

  • Builder Snippets contains pre-installed snippets used by the Search and New Record builders. These may be edited to change default HTML used in various places in the builders.
  • Column Snippets contains context-sensitive column snippets, used in the Search action, the Search Builder, and the New Record Builder.

For more information, see "Shortcuts to Configuration Variable Assignments: Snippets"..

For more information on configuration variables, see the Meta Tags and Configuration Variables manual.

  • Configuration Variables contains pre-installed snippets of the Tango configuration variables. They are organized by category and by variable scope.
  • My Snippets contains snippets you create and edit.
  • Standard Snippets contains pre-installed snippets, which are not editable.
[top] [back to top]


Working With Snippets

Inserting Snippets

To insert a single snippet into an application file

Do one of the following:

  • Drag the snippet to the text field you want (for example, the Results editing HTML window).
  • Place your cursor where you want the snippet inserted, then double-click the snippet (HTML editing windows only).
  • Control+click on the snippet and choose Insert from the contextual menu that appears.
  • Control+click on the snippet and choose Copy from the contextual menu that appears. Control+click in an editing window, and choose Paste from the contextual menu.
To insert multiple snippets into an application file
  1. Select the snippets you want to drag by doing one of the following:
    • Click a snippet, hold down the Shift key, and click the last item you want to select. All items in order between the first and last snippet you clicked are selected.
    • Click a snippet, hold down the command key, and select additional snippets (discontiguous selection).
  2. Insert the snippets by doing one of the following:
    • Drag the snippets into the text field you want.
    • Place your cursor where you want the snippet inserted, then double-click the snippets to insert them.
    • Control+click on the snippets, and choose Insert from the contextual menu that appears.
    • Control+click on the snippets, and choose Copy from the contextual menu that appears. Control+click in an editing window and choose Paste from the contextual menu that appears.

Creating and Editing Snippets

You can create your own snippets in the My Snippets folder to automate repeated tasks. You can also edit snippets in the Builder Snippets folder, or copy other snippets into the My Snippets folder to customize them to your needs.

Editable and Non-Editable Snippets
  • Editable snippets can be edited, copied, inserted, deleted and renamed. You can also show their properties. Snippets in the Builder Snippets and My Snippets folders are editable.
  • Non-editable snippets cannot be edited, deleted, nor renamed. You can copy their contents to the clipboard, and show their properties. Snippets in the Column Snippets, Configuration Variables, and Standard Snippets folders are non-editable.
To create a snippet with new text
  1. Do one of the following:
    • From the Edit menu, choose New Snippet....
    • control+click in the My Snippets folder of the Snippets Workspace, and select New Snippet from the contextual menu that appears.

    The New Snippet window appears.

  2. Fill in the window as follows.

    Name. Assign a name to the new snippet.

    Create in this folder. The My Snippets folder is shown by default. Select where you want to create the new snippet.

  3. Click OK.

    The Snippet contents window appears.

  4. Type in the content of your snippet or insert text from elsewhere.
Using Placeholders in Snippets

When you control+click the Snippet contents window, the Insert Placeholder command is listed in the contextual menu that appears, in addition to the standard Tango editing commands.

Insert Placeholder inserts a special symbol--the yen symbol, ¥--into the Snippet contents window. You can also enter this character by typing option+Y. This placeholder character allows you to create snippets that put HTML tags or meta tags around text you select before inserting the snippet. For example, you can create a snippet of the following text:

<H1>¥</H1>

To use this snippet while editing HTML, you select the text you want to apply the <H1> format to, and then drag the snippet into the editing window or double-click the snippet. The selected text is surrounded by the <H1> and </H1> tags.

Editing Snippets
To edit the contents of a snippet
  1. Do one of the following:
    • Control+click the snippet you want to edit, and choose Edit from the contextual menu that appears.
    • Hold down the command key and double-click the snippet.

    The Snippet content window appears:

  2. Edit the text.

    You can edit multiple snippets. Choosing Edit from the contextual menu opens the contents window for all the selected snippets.

Managing Snippets and Snippets Folders

You can create new folders to organize your snippets in the My Snippets folder. This feature is useful if you want to categorize your snippets by type (for example, meta tags, SQL, HTML, and text snippets). Snippet Properties allows you to see the location and size of snippets and snippet folders.

Creating a Snippets Folder
To create a new folder in the My Snippets folder
  1. Do one of the following:
    • Select the My Snippets folder. From the Edit menu, select Snippet, and then choose New Folder.
    • Control+click the My Snippets folder, and choose New Folder from the contextual menu that appears.

    A folder called Untitled appears. The name is already selected so you can change it.

  2. Type in a different name.
To rename a snippet or snippet folder
  1. Select a snippet or snippet folder, and do one of the following:
    • From the Edit menu, choose Rename.
    • Click the snippet or snippet folder again.
    • Control+click the snippet or snippet folder, and choose Rename from the contextual menu that appears.
  2. The name of the snippet or snippet folder becomes editable; type in the new name.

! Note: Snippet names must be unique inside a folder.


Snippet Properties
To see the properties of a snippet or snippet folder
  1. Select the snippet or snippet folder.
  2. Do one of the following:
    • From the Windows menu, choose Properties.
    • Type command+\.
    • Control+click the snippet or snippet folder, and choose Properties from the contextual menu that appears.

The Snippet Properties or Snippet Folder Properties dialog box appears.

The Snippets Folder Properties and Snippets Properties dialog boxes displays the name and location of the snippet folder or snippet; the Snippets Properties dialog box also displays the size and last modified date of the snippet.

Once you have the Properties dialog box open, clicking on different snippets or snippet folders displays the properties of that snippet or snippet folder.

Deleting Snippets

To delete a snippet or snippet folder
  1. Select the snippet or snippet folder.
  2. Do one of the following:
    • From the Edit menu, choose Clear.
    • Press Delete.
    • Control+click the snippet or snippet folder, and choose Delete from the contextual menu that appears.

    A dialog box appears, asking you to confirm that you want to delete the snippet.

  3. Click OK.

! Note: You can delete items from only the My Snippets and Builder Snippets folders.

If you want to delete multiple snippets, select the snippets and choose Delete from the contextual menu.


[top] [back to top]


Column Snippets

The Column Snippets area of the Snippets Workspace becomes active when the following are displayed:

  • Results HTML of the Search action.

    The Search action's Select columns appear and the Columns Snippets folder expanded, if necessary. (The Search action appears in the actions generated by the New Record Builder and Search Builder, as well as a separate action.)

  • New Record Response HTML in the New Record Builder.

    Shows all the columns from the table into which the new record is being added.

For more information, see "<@COLUMN>" in the Meta Tags and Configuration Variables manual.

The content of each snippet is <@COLUMN name>, where the column name is the name from the Search action or New Record Builder you are editing.



[TOC] [Prev] [Next] [Bottom]



docs@pervasive.com

Copyright © 1999, Pervasive Software. All rights reserved.