Asset Bundles : how to conditionally set content of a template file

GeKo
Contributor

Hello,

since Asset Bundles is based on GO templating mechanism, I am wondering how it is possible to use IF-ELSE construct within a template file, to define which file content will be set in the generated file ( I want to have that in my custom template).

Example: I am providing a boolean variable "topic_sourcing" to the bundle init command. The following template file shall be set, depending on that variable:

 

---
version: "1.0"
{{- if .topic_sourcing }}
status: enabled
topics:
  - name: "my-name"
    table_name: "my-tablename"
{{- else }}
status: disabled   
{{- end }}

 

But after the bundle init command, it looks like there is no templating mechanism applied on the file, means the created file contains exactly the text shown above.

How can I populate a file content based on a variable during bundle init ??