Drone template with optional parameter

I am trying to update an existing template to have a new step that is skipped if a parameter passed in is not there or is false.

I would like the template to work in both these scenarios:

kind: template
load: test_template.yaml
  do_thing: false


kind: template
load: test_template.yaml

My template currently looks something like this (I have stripped out all the other steps for sake of ease):

kind: pipeline
type: docker
name: test_pipeline

    - push

  - name: skippable-step
    image: <SOME BUILD AGENT>
    pull: always
      - echo passed in value - {{ .input.do_thing }}
      - |
        if [[ ! -z "{{ .input.do_thing }}" ]] && [[ "{{ .input.do_thing }}" == "true" || "{{ .input.do_thing }}" == "1" || "{{ .input.do_thing }}" == "TRUE" ]] ; then 
          echo "It did a thing"

The step is essentially just trying to check if the value is there and if it’s true it executes.

Currently the step fails with the following logs:

+ echo passed in value - <no value>
/bin/sh: line 39: syntax error near unexpected token `newline'

Are there any ways to have optional parameters?
Can we set them to default values when not passed in?
How can I roll out an optional step without breaking existing users of the pipeline if optional parameters are not allowed?

An update on the above question. I did manage to fix the above issue by removing the log.

However, I would still like to know if there is a way to have optional parameters without these complicated bash commands?

It would be great if there is a way to set a default value to parameters that were not passed in by the consumer?

Hey Jordan, welcome to the community :confetti_ball:

I went through your query and maybe drone conditions can help you tackle this issue of optional parameter.
You may use -
when : your condition
and exclude/include: to include or exclude the step.

Check this Event section of drone docs for a detailed example - here

I hope this helps. :raised_hands: