refactor(Template): Deprecate init from files
This commit is contained in:
@@ -50,6 +50,11 @@
|
|||||||
{% endfilter %}
|
{% endfilter %}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Deprecations
|
||||||
|
|
||||||
|
- `Template` initialisers have been deprecated in favour of using a template
|
||||||
|
loader such as `FileSystemLoader` inside an `Environment`.
|
||||||
|
|
||||||
|
|
||||||
## 0.7.1
|
## 0.7.1
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public class Template: ExpressibleByStringLiteral {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a template with the given name inside the given bundle
|
/// 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 {
|
public convenience init(named:String, inBundle bundle:Bundle? = nil) throws {
|
||||||
let useBundle = bundle ?? Bundle.main
|
let useBundle = bundle ?? Bundle.main
|
||||||
guard let url = useBundle.url(forResource: named, withExtension: nil) else {
|
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
|
/// 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 {
|
public convenience init(URL:Foundation.URL) throws {
|
||||||
try self.init(path: Path(URL.path))
|
try self.init(path: Path(URL.path))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a template with a file found at the given 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 {
|
public convenience init(path: Path, environment: Environment? = nil, name: String? = nil) throws {
|
||||||
self.init(templateString: try path.read(), environment: environment, name: name)
|
self.init(templateString: try path.read(), environment: environment, name: name)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user