hyTags
HomeHome DocumentationDocumentation

if-not-nil

Executes commands if a value of the specified type is found on the stack.
Parameter
Type
Description
type
Type?
The type to check for on the stack. If not specified, checks for any value.
return
Type?
The expected return type from the commands
commands
Commands
Commands to execute if a matching value is found
return
void
The return value from the executed commands, if any
Test Case:Executes commands when value exists
    <div></div>
    
    <string-new value="exists">
    <if-not-nil type="string" return="string">
      <string-new value="found">
    </if-not-nil>
    <assert-equal value="found" type="string">
    
    👆 Try to change something!
  • Test Case:Does not execute commands when value is nil
      <div></div>
      
      <var-set name="result" value="default"></var-set>
      <if-not-nil type="string">
        <var-set name="result" value="found"></var-set>
      </if-not-nil>
      <var-get name="result">
      <assert-equal value="default" type="string">
      
      👆 Try to change something!
    • Test succeeded Test failed