Functions

Contents

Syntax

The syntax for Nift function calls is as follows:

f++:  
funcName{options}(params)

n++:  
@funcName{options}(params)

Below is an example of a function call with no options:

@input("$[contentpath]")

You can also expand multiple options or parameters when parsing the options or parameters string. A contrived n++ example that is equivalent to calling @funcName(param_1, param_2) is below:

@string str = "param_1, param_2"
@funcName($[str])

Note: you need to quote the function name when printing variables or calling functions in the function name. A contrived n++ example is below:

@string str = "input"
@"$[str]"("$[contentpath]")

Nift is pretty good at working out when it does or does not need to parse things like the function name, options and/or parameters. You can manually tell Nift to not parse the function name and parameters using the !p option. For example:

@input("${!p}[contentpath]")

Note: For options and parameters (including variable names and values), you can use:

  • \n for the newline character
  • \t for tabs (though normal tabs also work)
  • \\ for \
  • \' for '
  • \" for "

Function names, options and parameters (including variable names and values) can be unquoted, single quoted or double quoted, whichever is more convenient, integrates with the other programming, scripting and/or template languages you are using and/or has nice syntax highlighting with the extensions and editor(s) you are using. Also for functions that can take multiple parameters, parameters containing commas , should be quoted, there can also be other times that things need to be quoted, for example if you want to have equals = in a variable name during its definition then it will need to be quoted (though will not need to be quoted when referenced).

Options

The following options are available for most function calls:

option description
!p do not parse parameters
v replace variables with their values (where applicable)
!v do not replace variables with their values (where applicable)
1p treat parameter string as one parameter
option description

The following options are available for user-defined function calls:

option description
mf add member functions for options, params and types vectors
!mf do not add member functions for options, params and types vectors
o add output
!o do not add output
s add scope
!s do not add scope
option description
[index]

Index

Below is an index of Nift's hard-coded functions (including functions for defining variables, functions and structures/types) which can be called from f++ and n++: