1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-04 00:56:17 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/functions/Functions.tid

29 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-10-09 12:54:33 +00:00
created: 20221009124003601
modified: 20230419103154328
2022-10-09 12:54:33 +00:00
tags: Concepts Reference
title: Functions
type: text/vnd.tiddlywiki
!! Introduction
2022-10-09 16:34:22 +00:00
<<.from-version "5.3.0">> A <<.def function>> is a named snippet of text containing a [[Filter Expression]]. Functions can have named parameters which are available within the function as variables.
2022-10-09 12:54:33 +00:00
Functions are usually defined with the [[Pragma: \function]]:
```
\function my-function(parameter:"2")
[<parameter>multiply[1.5]]
\end
```
Functions can be invoked in several ways:
* Directly transclude functions with the syntax `<<myfn param:"value">>`
* Assign functions to widget attributes with the syntax `<div class=<<myfn param:"value">>>`
* Invoke functions via the [[function Operator]] with the syntax `[function[myfn],[value],...]`
* Directly invoke functions whose names start with a period as custom filter operators with the syntax `[.myfn[value]]`
!! How Functions Work
Functions are implemented as a special kind of [[variable|Variables]]. The only thing that distinguishes them from ordinary variables is the way that the parameters are handled.