hyTags
HomeHome DocumentationDocumentation

if-nil

Executes commands if no 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 no matching value is found
return
void
The return value from the executed commands, if any
Test Case:Executes commands when value is nil
    <div></div>
    
    <if-nil type="string" return="string">
      <string-new value="was nil">
    </if-nil>
    <assert-equal value="was nil" type="string">
    
    👆 Try to change something!
  • Test Case:Does not execute commands when value exists
      <div></div>
      
      <var-set name="result" value="default"></var-set>
      <string-new value="exists">
      <if-nil type="string">
        <var-set name="result" value="was nil"></var-set>
      </if-nil>
      <var-get name="result">
      <assert-equal value="default" type="string">
      
      👆 Try to change something!
    • Test succeeded Test failed