#! sometimes it is useful to extract common
#! functionality into functions

#@ def some_data():
#@   return [1,2,{"key":"value"}]
#@ end

simple_key: #@ some_data()

#! functions can also return YAML fragments
#! that can be used as standard values

#@ def some_yaml():
name: max
cities:
- SF
- LA
#@ end

yaml_key: #@ some_yaml()

#! functions with scalar return values must be written
#! in Starlark

#@ def some_scalar():
#@   return "hello world"
#@ end

scalar_key: #@ some_scalar()

---
#! if the YAML node inside the function
#! is not compatible with the surrounding context
#! (here an array and map would be siblings due to scalar_key),
#! functions can be declared in separate YAML documents
#! to reset the context

#! to avoid splitting the current document,
#! definitions can happen in a separate file or
#! at the top of the document

#@ def some_list():
- item1
#@ end

---
yaml_list_key: #@ some_list()

#! and since functions return just values you
#! can use them any way you want, for example,
#! as document values

--- #@ some_scalar()
--- #@ some_yaml()
--- #@ some_list()
