plus¶
The plus filter adds a specified number to the input number. It is a fundamental arithmetic operation for calculations within your templates.
Functionality
- Numbers: Takes a numerical value as input (integer or floating-point).
- Addend: Requires a numerical argument specifying the number to add.
- Addition: Adds the second number (the addend) to the first number (the input).
- Output: Returns a new numerical value representing the result of the addition.
Syntax
Arguments
- addend: The numerical value to add to the input number.
Code Samples
Example 1: Adding a Positive Number
Output: Example 2: Adding a Negative Number Output: Example 3: Adding Decimals Output:Outliers and Special Cases¶
- Non-Numeric Input: If the input or the addend is not a number (e.g., a string), the filter might attempt to convert it to a number. If the conversion fails, an error might be thrown.
Key Points¶
- The
plusfilter is a basic but essential arithmetic operation for working with numbers in templates. - It is useful for calculating totals, aggregating values, or any scenario where you need to add one value to another.
- The order of the values does not matter in addition.
- Be mindful of data types to ensure correct behavior and avoid errors.