Skip to content

Instantly share code, notes, and snippets.

@grdsdev
Created January 12, 2022 10:00
Show Gist options
  • Select an option

  • Save grdsdev/381826e7b4f1c1764fba80baf720d9f8 to your computer and use it in GitHub Desktop.

Select an option

Save grdsdev/381826e7b4f1c1764fba80baf720d9f8 to your computer and use it in GitHub Desktop.
{% for type in types.structs %}
{% if type|annotated:"AutoInit" %}
{% set spacing %}{% if type.parentName %} {% endif %}{% endset %}
{% map type.storedVariables into parameters using var %}{{ var.name }}: {% if var.typeName|hasPrefix:"(" %}@escaping {% endif %}{{ var.typeName }}{% endmap %}
// sourcery:inline:auto:{{ type.name }}.AutoInit
{{spacing}}{{ type.accessLevel }} init({{ parameters|join:", " }}) {
{{spacing}} {% for variable in type.storedVariables %}
{{spacing}} self.{{ variable.name }} = {{ variable.name }}
{{spacing}} {% endfor %}
{{spacing}}}
// sourcery:end
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment