Tinderbox v9 Icon

exportedString(item[, templateStr])


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

 Function  [other Function type actions]

 Item  [operators of similar scope]

 Formatting  [other Formatting operators]

 Baseline

 As at baseline


exportedString(item[, templateStr])

The operator exportedString() applies an export template to a note, returning the result as a String.

item designates the note to be exported; and is a note name, path or item designator. An attribute may not be used as a placeholder for such information. By default, the note used is the current note, i.e. 'this'. exportedString() also binds 'current' designator to 'this' when resolving item.

The second argument, templateStr, has three forms.

In the short, single argument, usage the template to evaluate is not supplied as the target note's inherited or locally assigned template is used. In long-lived projects, it can be useful to use the two-argument form (assuming the template assignment will not change!). Doing this makes it easier to see in code which template will be used rather than have to go and look up that value. Making such a change has no performance input.

The exportedString() operator is especially useful in conjunction with the runCommand() operator. You can use exportedString() to assemble the input an external program will require, and then pass that input to the external program.

If you simply wish to transform a string or attribute value (e.g. $Name) into a 'safe' value for use as an HTML/XML element 'id' value, a possible alternative is to use idEncode().

Examples

exportedString(item)

Use of exportedString with just the target item. If using only the (unique) note $Name, it should should be quote-enclosed.

$MyString = exportedString("Some Note"); 

or using a full $Path for the template, do not use quotes:

$MyString = exportedString(/Projects/X/Some Note); 

exportedString(item, templateStr) 

The first form using templateStr takes a reference to a note and the name of a template note and returns the result of applying the template to the note. If item is a path or title, the value requires quotes:

$MyString = exportedString(this,"tSome_Template"); 

$MyString = exportedString("Some note","tSome_Template"); 

or use the unquoted full $Path for the template:

$MyString = exportedString(this,/Templates/tSome_Template); 

The second form using templateStr requires as its second argument is the template string itself which may be a reference to an attribute or action code variable:

$MyString = exportedString(this,$MyTemplateCode); 

$MyString = exportedString(this,vTemplate); 

The third form using templateStr requires as its second argument some literal code:

$MyString = exportedString("/Path/To/Some note","^text^"); 

$MyString = exportedString("/Path/To/Some note","^value($Name(parent))^");