Named Parameters

Release 1.0 - ...

Viper methods support four predefined named parameters; default, error, rem and whitespace.

The viper in this example will return the value 'none' if the query parameter 'nonexistingparam' does not exist.

Smartsite SXML CopyCode image Copy Code
{request.query(nonexistingparam,default=none)}

Default parameter

The default parameter is used when:

  • The viper context is compatible with the context in which the viper is resolved.
    If not, the viper is left untouched.
  • If the viper returns null as its result.

Whenever the viper returns a null token and the default parameter is not set, the viper is left unresolved.

Error parameter

The error parameter is used when an uncaught exception is raised during the execution of the viper.

Smartsite SXML CopyCode image Copy Code
{string.eval('1/0', error='invalid expression')}

Rem parameter

The rem parameter represents a remark that you can add to any viper to describe the purpose of the call.

Whitespace parameter

The whitespace parameter is used to override the whitespace handling used when executing vipers. By default, the whitespace setting of the enclosing macro will be used.

Nested viper methods

When a nested viper method returns a null token and this nested result is used during the processing of its parent viper method, the outer method will also return the null token (i.e. remain unresolved), unless the default parameter is set.

Similar to the above example above, this example will return the value 'empty' when the query parameter 'nonexistingparam' does not exist.

Smartsite SXML CopyCode image Copy Code
{string.toupper(request.query(param, default=empty))}