assign

The assign parameter to many NATS functions lets you change output variable names. For example, the NATS template function, nats_decode, creates the following variable by default:

  • {$encoded}

Unfortunately, if you already have a Smarty variable named $encoded when you call nats_encode, the new value overwrites the old value. We designed assign to solve this problem. Call nats_encode with an argument to the assign parameter to have its output placed in the variable named by your argument.

For example: the following code,

  • {nats_encode assign="my_variable"}

Puts the output in,

  • {$my_variable}

Last updated

Was this helpful?