Export 1

This is Tinderbox Cookbook version 1.0.0, created in conjunction with Tinderbox 5.5.4b1.

This page explores Tinderbox export elements, used in export templates. Export templates can also be used in some actions, but this syntax is now deprecated. Export template elements begin with the character ^. This page covers all the export codes except those relating to creation of links, which are covered in part 2 of the page.

^action( action )^

Perform the specified action code, possibly changing the values of one or more attributes. Nothing is exported.

description try expect result ok
^action($UserString="Hello!")^^get(UserString)^ Hello! Hello! not yet
^action($UserString="Hello")^^action($UserString="Adieu")^^get(UserString)^ Adieu Adieu not yet

^any( group , attribute[, data] )^

Returns true if any member of the group has a value for the given attribute. Alternatively, it returns true if the specified data is matched.

Examples are based on the following data:

Name UserFlag UserNum
apple true 12
pear false 3
lemon false 3
lime true 2
description try expect result ok

Just an attribute. For this test to return false all children must have $UserFlag value of false.

^any(child,$UserFlag)^ true true not yet
^any(child,$UserFlag,false)^ true true not yet
^any(child,$UserNum,3)^ true true not yet
^any(child,$UserNum,42)^ false false not yet

For non-Boolean fields any value other than the standard defaults (empty string/set, zero number, never date) is coerced to 'true'.

^any(child,$UserNum)^ true true not yet

Using action code

^value(any(child,$UserFlag))^ true true not yet

Using action code

^value(any(child,!$UserFlag))^ true true not yet

Using action code

^value(any(child,$UserNum==3))^ true true not yet

Using action code

^value(any(child,$UserNum==42))^ false not yet

Using action code.

For non-Boolean fields any value other than the standard defaults (empty string/set, zero number, never date) is coerced to 'true'.

^value(any(child,$UserNum))^ true true not yet

^backslashEncode( data )^

Prefaces single and double quotation marks in data with a single backslash.

description try expect result ok

Note source string's double set of quotes as the outer pair are the parameter string delimiters. The inner pair are part of the string actually ecoded for output

^backslashEncode(""Fiddlesticks!"")^ \"Fiddlesticks!\" \"Fiddlesticks!\" not yet

UserString is "Fiddlesticks!".

^backslashEncode("^get(UserString)^")^ \"Fiddlesticks!\" \"Fiddlesticks!\" not yet

UserString is \"Fiddlesticks!\".

^backslashEncode("^get(UserString)^")^ \\\"Fiddlesticks!\\\" \\\"Fiddlesticks!\\\" not yet

beginsWith

Tests if the target string begins with the data string. Unlike contains(), beginsWith uses simple string match, not regular expressions.

description try expect result ok
^beginsWith(frost kitten,frost)^ "true" "true" not yet

beginsWith does not match regular expressions

^beginsWith(frost kitten,fr.st)^ false not yet

$Name is frosty morning .

^beginsWith(^get($Name)^,frost)^ "true" "true" not yet

$Name is summer evening.

^beginsWith(^get($Name)^,"frost")^ not yet

test name ($TestName is 'frosty morning'. UserString is 'frosty'.

^beginsWith(^get($TestName)^,^get($UserString)^)^ "true" "true" not yet

Name ($TestName) is 'frosty morning'. $UserString is 'Hamlet'.

^beginsWith(^get($TestName)^,^get($UserString)^)^ not yet

^capitalize( data )^

Transforms a string or attribute to use initial capitals.

description try expect result ok

Use a literal string.

^capitalize(frosty friday)^ Frosty Friday Frosty Friday not yet

Use a literal string. Only the initial letters are capitalised.

^capitalize(fROSTY fRIDAY)^ FROSTY FRIDAY FROSTY FRIDAY not yet

Use a literal string. Only the initial letters are capitalised.

^capitalize(frOSTy friDaY)^ FrOSTy FriDaY FrOSTy FriDaY not yet

Don't use quotes around the string value. Doing so causes the argument not to be processed.

^capitalize("frosty friday")^ Frosty Friday "frosty Friday" not yet

The value of $UserString is 'frosty friday'.

^capitalize(^get(UserString)^)^ Frosty Friday Frosty Friday not yet

Don't use quotes around the string value. 

The value of $UserString is 'frosty friday'.

^capitalize("^get(UserString)^")^ Frosty Friday "frosty Friday" not yet

You must use ^get^ or ^getFor^ to access attribute values. 

The value of $UserString is 'frosty friday'.

^capitalize($UserString)^ Frosty Friday $UserString not yet

The ^value^ here is not needed as ^get^ returns the attribute value - see above. 

The value of $UserString is 'frosty friday'.

^capitalize(^value(^get(UserString)^)^)^ Frosty Friday "frosty Friday" not yet

The value of $UserString is 'frosty friday'.

^capitalize(^value(eval($UserString))^)^ Frosty Friday Frosty Friday not yet
^value(capitalize(fROSTY fRIDAY))^ FROSTY FRIDAY FROSTY FRIDAY not yet
^value(capitalize($UserString))^ FROSTY FRIDAY FROSTY FRIDAY not yet

^children( [template] )^

Includes only the immediate children of the current note (or agent) in the current Web page using their default template file or with the specified template file.

In Tinderbox versions prior to 4.6, ^children() exported all descendants and ^justChildren exported immediate children. From 4.6 on, ^children exports immediateChildren and is a synonym for ^justChildren, whole ^descendants exports all the descendants of a note.

description try expect result ok

^cloud( item, count] )^

Exports the information displayed in the Common Words view, note tab.

description try expect result ok

^comment( data )^

All of the data within the parentheses of the comment is ignored when using the template to create Web pages.

description try expect result ok

Exports a standard HTML comment.

^comment(This is a comment)^ <!-- This is a comment --> <!-- This is a comment --> not yet

^contains( target, data )^

Tests if the target string contains the data string using regular expressions.

description try expect result ok
^contains(frosty morning,frost)^ true true not yet
^contains(frosty morning,ocelot)^ false false not yet
^contains(frosty morning,fr.st)^ true true not yet

^count( group )^

Counts the number of notes within the specified group (container or group placeholder).

Data for the examples is taken from the following example, taken from /data/todo.

description try expect result ok
^count(child(/data/todo))^ 4 4.00 not yet
^count(child(/data/todo/Groceries))^ 3 3.00 not yet
^count(child(/data/todo/Groceries/garlic))^ 0 0.00 not yet
^count(descendant(/data/todo))^ 14 14.00 not yet
^count(ancestor(/data/todo))^ 1 1.00 not yet
^count(ancestor(/data/todo/Groceries/garlic))^ 3 3.00 not yet

^created( item[, format] )^

Date/time (with optional formatting) of the creation of specified note based on $Created.

description try expect result ok
Test note ⇕ ^created(this,"m/d/y")^ 2/3/2009 2/3/2009 not yet

^creator( item )^

Name of the creator of the specified note as in $Creator (derived from Preferences).

description try expect result ok

Who made the current note? No item parameter supplied

^creator^ Cookbook Tester Cookbook Tester not yet

Who made 'this' note?

^creator(this)^ Cookbook Tester Cookbook Tester not yet

Who created note "Tinderbox Action and Export Cookbook"?

^creator(Tinderbox Action and Export Cookbook)^ system system not yet

^days( date, N )^

Tests if date is within N days of today.

description try expect result ok

$Date is 7/4/76 12:00 AM

^days(^get(Date)^,7)^ false not yet
^days(yesterday,7)^ true true not yet

^descendants( [template] )^

Includes all descendants (children, children of those children, etc.) of the current note (or agent) in the current Web page using their default template file or with the specified template file.

description try expect result ok

^directory( item )^

Name of the exported directory (i.e. parent folder name) of the note specified.

description try expect result ok

Test with no parameters - 'this' implied.

^directory^ Export1/directory/ Export1/directory/ not yet

Explicit 'this' reference.

^directory(this)^ Export1/directory/ Export1/directory/ not yet

Explicit reference to another note. Note 'Tinderbox Action and Export Cookbook' has its HTMLExportFilename set to 'index'.

^directory(Coping with HTML output)^ index/ index/ not yet

^do( theMacro [,argument, anotherArgument, etc.] )^

Execute the named macro (macro must already be defined in the current TBX).

description try expect result ok

^docTitle^

The name of the current Tinderbox document (i.e. the OS filename). The '.tbx' file extension is omitted if present.

description try expect result ok

Show the Mac OS X filename of the current Tinderbox document.

^docTitle^ Tinderbox Cookbook Tinderbox Cookbook v554 mwra not yet

^documentCloud( [count] )^

Exports the information displayed in the Common Words view, document tab.

description try expect result ok

^else^

Branching code for ^if conditional statements. See also ^else^ and ^endIf^.

description try expect result ok

^encode( [data] )^

Encodes the argument string, replacing common non-ASCII characters with the corresponding HTML entities in &#NNNN form where NNNN is 2 or more characters holding a hexadecimal number value. For example, '&' is converted to '&amp;'

NOTE: since the move to utf-8 output, the need for this code has reduced. Indeed, using it may cause double-encoding to occur so the entities are shown rather then the intended character they represent.

description try expect result ok

In this case, the entity's ampersand has been double-encoded to show the actual entity code. In real use the character on screen would be a ü as drawn by an '&#xfc;' code.

^encode(Hückel)^ H&#xfc;ckel H&#xfc;ckel not yet

^endIf^

Closing code for ^if statements, use being optional. See ^if and ^else^

description try expect result ok

^endsWith( )^

Tests if the target string ends with the data string using simple string matching, in contrast to false which matches regular expressions.

description try expect result ok
^endsWith(frosty morning,morning)^ true true not yet
^endsWith(frosty morning,night)^ false false not yet
^endsWith(frosty morning,m...ing)^ false false not yet

^equal( data1, data2 )^

Returns the Boolean result of comparing data1 string with data 2 string. Primarily used with

description try expect result ok

^every( group , attribute[, data] )^

Returns true if every member of the group has a value for the given attribute. Alternatively, it returns true if the specified data is matched.

Examples are based on the following data:

Name UserFlag UserNum
apple true 12
pear false 3
lemon false 3
lime true 2
description try expect result ok

Just an attribute. For this test to return false all children must have $UserFlag value of false.

^every(child,$UserFlag)^ false false not yet
^every(child,$UserFlag,false)^ false false not yet
^every(child,$UserNum,3)^ false false not yet

For non-Boolean fields any value other than the standard defaults (empty string/set, zero number, never date) is coerced to 'true'.

^every(child,$UserNum)^ true true not yet

^exists( item | attribute)

Returns a Boolean evaluation within an ^if condition of whether an item note/object exists or if an attribute holds a value.

description try expect result ok

^file( item )^

The filename of the file for the web page of a item (or note), i.e. $HTMLExportFileName.

description try expect result ok

^firstWord( data )^

Extracts the first word from the data string/

description try expect result ok
^firstWord(We hold these truths to be self-evident)^ We We not yet

^get( )^

fetch the value of any attribute of this note. If the optional second attribute is supplied, it specifies the formatting to be used. This allows custom formatting of dates.

description try expect result ok

Name is 'simple'.

^get($Name)^ simple simple not yet

$Date is December 7, 2008

For UK system try Expected = "7 December 2008"

For US system try Expected = "7 December, 2008" (N.B. comma)

^get($Date,"L")^ 7 December 2008 December 7, 2008 not yet

$TestBoolean is set to true using an ^action^ call in $Try.

^action($TestBoolean=true)^^get($TestBoolean)^ true true not yet

$TestBoolean is set to false using an ^action^ call in $Try.

^action($TestBoolean=false)^^get($TestBoolean)^ false false not yet

^getFor(path | item, attribute[, format] )^

Fetch the value of any attribute of the note cited as a path or item. If the optional third attribute is supplied, it specifies the formatting to be used. This allows custom formatting of dates.

description try expect result ok

^host^

The host of the site of this Web page, derived from HTML preferences' URL.

A trailing backslash is supplied, if one is not supplied in the source preference (q.v. ^root^).

description try expect result ok

URL in TBX's HTML preferences is 'http://www.example.com'.

^host^ http://www.example.com/ not yet

^if( condition )^

Tests if condition is true. The condition may use agent query syntax for expressions

description try expect result ok

^include( item[, template] )^

Includes a single item or note (with its default template) in the web page for the current note. If template is supplied, that will be used to process the included material)

description try expect result ok

^indent( data )^

Exports the data as a string (sequence of characters) for each ancestor of the currently exported note, i.e. one indent per outline level, except the root. If data is not supplied a tab character is emitted per indent.

description try expect result ok

^isDescendedFrom( item )^

Boolean test if item is a descendant of the object in current scope.

description try expect result ok
^isDescendedFrom(parent)^ true true not yet
^isDescendedFrom(../..)^ true true not yet
^isDescendedFrom(nextSibling)^ false false not yet
^isDescendedFrom(/NoSuchNote)^ false false not yet

UserString is "parent"

^isDescendedFrom(^get(UserString))^ true true not yet

^isInside( item )^

Boolean test if item is a direct child of the object in current scope.

description try expect result ok
^isInside(parent)^ true true not yet
^isInside(../..)^ false false not yet
^isInside(nextSibling)^ false false not yet
^isDescendedFrom(/NoSuchNote)^ false false not yet

^justChildren( [template] )^

Includes only the immediate children of the current note (or agent) in the current Web page using their default template file or with the specified template file.

From v4.6 this is the same as ^children^ and deprecated in favour of the latter.

description try expect result ok

^lastModified( item[, format] )^

Date/time (with optional formatting) of the creation of specified note based on $Modified.

description try expect result ok

^lastWord( data )^

Extracts the final word from the argument

description try expect result ok
^lastWord(We the people)^ people people not yet

Alternative: use lastWord()

^value(lastWord("We the people"))^ people people not yet

^lowercase( data )^

Transforms a string or attribute to use all lower case.

description try expect result ok

Value is string 'Zoo'.

^lowercase(Zoo)^ zoo zoo not yet

$UserString is "Zoo".

^lowercase(^get(UserString)^)^ zoo zoo not yet

^max( group , attribute[, precision] )^

Returns the maximum value of an attribute in the designated group, with an optional precision.

Examples are based on the following data:

Name UserFlag UserNum
apple true 12
pear false 3
lemon false 3
lime true 2
description try expect result ok
^max(child(/data/fruit),UserNum)^ 12 12.00 not yet

Unlike the action function max(), ^max does not compare strings

^max(child(/data/fruit),Name)^ pear 0.00 not yet

^mean( group , attribute[, precision] )^

Returns the arithmetical mean value of an attribute in the designated group, with an optional precision.

Examples are based on the following data:

Name UserFlag UserNum
apple true 12
pear false 3
lemon false 3
lime true 2
description try expect result ok
^mean(child(/data/fruit),UserNum)^ 5 5.00 not yet

^min( group , attribute[, precision] )^

Returns the minimum value of an attribute in the designated group, with an optional precision.

Examples are based on the following data:

Name UserFlag UserNum
apple true 12
pear false 3
lemon false 3
lime true 2
description try expect result ok
^min(child(/data/fruit),UserNum)^ 2 2.00 not yet
^min(child(/data/negatives),UserNum)^ -4 -4.00 not yet

^not( condition )^

If the enclosed condition is normally false, this makes it true and vice versa. Most commonly used with ^if statements.

description try expect result ok
^not(true)^ false false not yet
^not(false)^ true true not yet
^not(^equal(2,2)^)^ false false not yet
^not(^equal(2,frogs)^)^ true true not yet

^opmlEncode( data )^

description try expect result ok

This is paragraph 1.

This is paragraph 2.

^opmlEncode(^text(plain)) This is paragraph 1. This is paragraph 2. This is paragraph 1. This is paragraph 2. not yet

^paragraphs( [item,] N )^

Exports the first N paragraphs of the text of specified item (note). If item is not specified, content is drawn from 'this' note.

description try expect result ok

^path^

The relative path for this web page's file from the top-level directory you selected for storing HTML files to this file.

description try expect result ok
^path(/data/fruit/apple)^ data/fruit/apple.html data/fruit/apple.html not yet

^randomChildOf( item [, template] )^

Includes an export of a random child of the specified item or note through its default template or supplied named template.

description try expect result ok

^randomLine( item )^

Scans the text of a designated item or note (or, if no argument is supplied, the current note). The text is split at paragraph breaks (e.g. carriage returns), and one line (i.e. a paragraph) is chosen at random.

description try expect result ok

^root^

Returns the relative path from the current file to the directory that contains the cover page. A trailing backslash is supplied (q.v. ^host^).

description try expect result ok

^sectionCloud( [item, count] )^

Exports the information displayed in the Common Words view, section tab.

description try expect result ok

^sectionNumber( item )^

The hierarchical number of the item (note) based on the present hierarchy and outline sort order; it items is omitted scope is 'this'.

description try expect result ok
^sectionNumber(/data)^ 7 7 not yet
^sectionNumber(/data/fruit)^ 7.1 7.1 not yet
^sectionNumber(/data/fruit/apple)^ 7.1.1 7.1.1 not yet
^sectionNumber(/data/fruit/pear)^ 7.1.2 7.1.2 not yet

^setRoot( [newRoot] )^

tells Tinderbox to use its first argument (newRoot) as the value of ^root^ until either another ^setRoot^ is found or the current file being exported is complete. To restore relative URLs, use ^setRoot()^ with no arguments.

description try expect result ok

^sum( group , attribute[, precision] )^

Returns the sum of an attribute in the designated group, with an optional precision.

Examples are based on the following data:

Name UserFlag UserNum
apple true 12
pear false 3
lemon false 3
lime true 2
description try expect result ok
^sum(child(/data/fruit),UserNum)^ 20 20.00 not yet

^text( item[, N, plain] )^

Returns the body (text and graphics) of the item or note, i.e. includes any existing mark-up. If a note name is not specified, 'this' is assumed as the focus. If the note only contains an image, the image's tag (<img>) is exported.

Optionally, just the first N words of the text of the item or note may be returned and/or the the text can be returned plain without added HTML mark-up.

description try expect result ok

^title( item )^

The title of the item or note, i.e. the contents of $Name.

description try expect result ok

^today( [item] [, format] )^

The current date and time. It item is supplied, it is ignored; it is accepted for consistency with other date operators ike ^created and ^modified. The format argument is also optional.

description try expect result ok

Today is 7/14/10

^today^ 7/14/10 7/14/10 not yet

Today is Wednesday

^today("W")^ Wednesday Wednesday not yet

Today is in July

^today(this,"MM")^ July July not yet

^uppercase( data )^

Transforms a string or attribute to use all upper case.

description try expect result ok
^uppercase(frost)^ FROST FROST not yet

^urlEncode( data )^

item encodes URLs in accordance with RFC1738.

description try expect result ok
^urlencode(http://example.com/cgi.bin?search=two words)^ http://example.com/cgi.bin?search%3dtwo%20words http://example.com/cgi.bin?search%3dtwo%20words not yet

^value( expression )^

Evaluates an expression and returns it as a string.

description try expect result ok
^value(2+3)^ 5 5 not yet

UserString is "42"

^value($UserString)^ 42 42 not yet

UserString is "42". Since "UserString" is a string, "+" concatenates strings

^value($UserString+7)^ 427 427 not yet

UserNum is "42". Since "UserNum" is a number, "+" adds two numbers.

^value($UserNum+7)^ 49 49 not yet

^version^

Exports the version number of Tinderbox used to create this Web page. The number is exported as a string without a prefix, i.e. "4.6.0" not "v4.6.0".

description try expect result ok

The version string may vary as fixes and test versions are released. This test confirms that the version is 4.6.

^version^ 5.0.3b8 5.5.4b1 not yet