api:set

Version 23.0.9145


api:set


Use the api:set keyword to set a value in an attribute. If an attribute is set in an item that does not exist, the item is automatically created.

You have two ways to set a value using api:set:

  • Set the value parameter.
  • Set the value using the scope of the keyword itself. This is useful for large, multi-line, complex values.

Parameters

  • item: Used to specify the item in which the attribute is set. If no item is specified, the default item is used.
  • attr: The attribute name. You can also specify the item using dot notation (for example, item.prefix:attr).

    Note: A complete attribute name has a prefix and an attribute name, but the prefix is not required.

  • value: The value to assign to the attribute. If this parameter is not provided, the entire body of the api:set keyword is used as the value. This is convenient for setting long or multi-line values.
  • copyfrom: The attributes from the item specified in this parameter are copied to the item specified by the item parameter.

Control Attributes

None

Example

Use the scope of the keyword to set a value to the message attribute of the item named input:

<api:set item="input" attr="message">
  Dear [name],
  You have won a cruise trip to Hawaii.
  Please confirm your acceptance by [date].
  Thanks, [sales]
</api:set>

See Also

  • api:unset: Remove an attribute from an item.
  • api:setm: Set multiple attributes with only one keyword.