Created
December 4, 2020 14:52
-
-
Save arpitdsoni/368b29fefc04aeb00a38692933b2dd6c to your computer and use it in GitHub Desktop.
SwiftGen asset names template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// swiftlint:disable all | |
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen | |
{% if catalogs %} | |
{% set enumName %}{{param.enumName|default:"AssetNames"}}{% endset %} | |
{% set forceNamespaces %}{{param.forceProvidesNamespaces|default:"false"}}{% endset %} | |
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %} | |
{% macro enumStringsBlock assets %} | |
{% for asset in assets %} | |
{% if asset.type != "group" %} | |
{{accessModifier}} static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = "{{asset.value}}" | |
{% elif asset.items and ( forceNamespaces == "true" or asset.isNamespaced == "true" ) %} | |
{{accessModifier}} enum {{asset.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} { | |
{% filter indent:4 %}{% call enumStringsBlock asset.items %}{% endfilter %} | |
} | |
{% elif asset.items %} | |
{% call enumStringsBlock asset.items %} | |
{% endif %} | |
{% endfor %} | |
{% endmacro %} | |
// MARK: - {{enumName}} | |
{{accessModifier}} enum {{enumName}} { | |
{% if catalogs.count > 1 or param.forceFileNameEnum %} | |
{% for catalog in catalogs %} | |
{{accessModifier}} enum {{catalog.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} { | |
{% filter indent:2 %}{% call enumStringsBlock catalog.assets %}{% endfilter %} | |
} | |
{% endfor %} | |
{% else %} | |
{% call enumStringsBlock catalogs.first.assets %} | |
{% endif %} | |
} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment