-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswift_template.go
More file actions
38 lines (32 loc) · 831 Bytes
/
swift_template.go
File metadata and controls
38 lines (32 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
const swiftTemplate = `
{{define "enumTemplate"}}
public enum {{.Name}}: String, ResourceImageConvertible {
{{with .Values}}{{range .}}
case {{.Name}} = "{{.RawValue}}"{{end}}{{end}}
{{with .Nested}}{{range .}}
{{template "enumTemplate" .}}{{end}}{{end}}
}
{{end}}
// This code is autogenerated by Resourceful - do not modify
#if os(iOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif
public protocol ResourceImageConvertible {}
public extension ResourceImageConvertible where Self: RawRepresentable, Self.RawValue == String {
#if os(iOS)
public var image: UIImage? {
return UIImage(named: self.rawValue)
}
#elseif os(OSX)
public var image: NSImage? {
return NSImage(named: self.rawValue)
}
#endif
}
public enum Resource {
{{template "enumTemplate" .}}
}
`