refactor(Template): Deprecate init from files

This commit is contained in:
Kyle Fuller
2016-12-01 01:47:19 +00:00
parent f90597fba1
commit 24359489ce
2 changed files with 8 additions and 0 deletions

View File

@@ -50,6 +50,11 @@
{% endfilter %}
```
### Deprecations
- `Template` initialisers have been deprecated in favour of using a template
loader such as `FileSystemLoader` inside an `Environment`.
## 0.7.1

View File

@@ -23,6 +23,7 @@ public class Template: ExpressibleByStringLiteral {
}
/// Create a template with the given name inside the given bundle
@available(*, deprecated, message: "Use Environment/FileSystemLoader instead")
public convenience init(named:String, inBundle bundle:Bundle? = nil) throws {
let useBundle = bundle ?? Bundle.main
guard let url = useBundle.url(forResource: named, withExtension: nil) else {
@@ -33,11 +34,13 @@ public class Template: ExpressibleByStringLiteral {
}
/// Create a template with a file found at the given URL
@available(*, deprecated, message: "Use Environment/FileSystemLoader instead")
public convenience init(URL:Foundation.URL) throws {
try self.init(path: Path(URL.path))
}
/// Create a template with a file found at the given path
@available(*, deprecated, message: "Use Environment/FileSystemLoader instead")
public convenience init(path: Path, environment: Environment? = nil, name: String? = nil) throws {
self.init(templateString: try path.read(), environment: environment, name: name)
}