| Index: trunk/phase3/includes/parser/Parser.php |
| — | — | @@ -3947,6 +3947,9 @@ |
| 3948 | 3948 | * The callback function should have the form: |
| 3949 | 3949 | * function myParserFunction( &$parser, $arg1, $arg2, $arg3 ) { ... } |
| 3950 | 3950 | * |
| | 3951 | + * Or with SFH_OBJECT_ARGS: |
| | 3952 | + * function myParserFunction( $parser, $frame, $args ) { ... } |
| | 3953 | + * |
| 3951 | 3954 | * The callback may either return the text result of the function, or an array with the text |
| 3952 | 3955 | * in element 0, and a number of flags in the other elements. The names of the flags are |
| 3953 | 3956 | * specified in the keys. Valid flags are: |
| — | — | @@ -3960,8 +3963,27 @@ |
| 3961 | 3964 | * @param string $id The magic word ID |
| 3962 | 3965 | * @param mixed $callback The callback function (and object) to use |
| 3963 | 3966 | * @param integer $flags a combination of the following flags: |
| 3964 | | - * SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}} |
| | 3967 | + * SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}} |
| 3965 | 3968 | * |
| | 3969 | + * SFH_OBJECT_ARGS Pass the template arguments as PPNode objects instead of text. This |
| | 3970 | + * allows for conditional expansion of the parse tree, allowing you to eliminate dead |
| | 3971 | + * branches and thus speed up parsing. It is also possible to analyse the parse tree of |
| | 3972 | + * the arguments, and to control the way they are expanded. |
| | 3973 | + * |
| | 3974 | + * The $frame parameter is a PPFrame. This can be used to produce expanded text from the |
| | 3975 | + * arguments, for instance: |
| | 3976 | + * $text = isset( $args[0] ) ? $frame->expand( $args[0] ) : ''; |
| | 3977 | + * |
| | 3978 | + * For technical reasons, $args[0] is pre-expanded and will be a string. This may change in |
| | 3979 | + * future versions. Please call $frame->expand() on it anyway so that your code keeps |
| | 3980 | + * working if/when this is changed. |
| | 3981 | + * |
| | 3982 | + * If you want whitespace to be trimmed from $args, you need to do it yourself, post- |
| | 3983 | + * expansion. |
| | 3984 | + * |
| | 3985 | + * Please read the documentation in includes/parser/Preprocessor.php for more information |
| | 3986 | + * about the methods available in PPFrame and PPNode. |
| | 3987 | + * |
| 3966 | 3988 | * @return The old callback function for this name, if any |
| 3967 | 3989 | */ |
| 3968 | 3990 | function setFunctionHook( $id, $callback, $flags = 0 ) { |