refactor(loader): Rename TemplateLoader to Loader
This commit is contained in:
@@ -4,11 +4,9 @@
|
||||
|
||||
### Breaking
|
||||
|
||||
- `TemplateLoader` is now a protocol with the file system based loader now
|
||||
called `FileSystemLoader`. You will need to use `FileSystemLoader` instead.
|
||||
|
||||
- `TemplateLoader` `loadTemplate` methods are now throwing and now take labels
|
||||
for the `name` and `names` arguments.
|
||||
- `TemplateLoader` has been renamed to `FileSystemLoader`. The
|
||||
`loadTemplate(s)` methods are now throwing and now take labels for the `name`
|
||||
and `names` arguments.
|
||||
|
||||
- Many internal classes are no longer private. Some APIs were previously
|
||||
accessible due to earlier versions of Swift requiring the types to be public
|
||||
|
||||
@@ -19,7 +19,7 @@ class IncludeNode : NodeType {
|
||||
}
|
||||
|
||||
func render(_ context: Context) throws -> String {
|
||||
guard let loader = context["loader"] as? TemplateLoader else {
|
||||
guard let loader = context["loader"] as? Loader else {
|
||||
throw TemplateSyntaxError("Template loader not in context")
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class ExtendsNode : NodeType {
|
||||
}
|
||||
|
||||
func render(_ context: Context) throws -> String {
|
||||
guard let loader = context["loader"] as? TemplateLoader else {
|
||||
guard let loader = context["loader"] as? Loader else {
|
||||
throw TemplateSyntaxError("Template loader not in context")
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ import Foundation
|
||||
import PathKit
|
||||
|
||||
|
||||
public protocol TemplateLoader {
|
||||
public protocol Loader {
|
||||
func loadTemplate(name: String) throws -> Template?
|
||||
func loadTemplate(names: [String]) throws -> Template?
|
||||
}
|
||||
|
||||
|
||||
extension TemplateLoader {
|
||||
extension Loader {
|
||||
func loadTemplate(names: [String]) throws -> Template? {
|
||||
for name in names {
|
||||
let template = try loadTemplate(name: name)
|
||||
@@ -24,7 +24,7 @@ extension TemplateLoader {
|
||||
|
||||
|
||||
// A class for loading a template from disk
|
||||
public class FileSystemLoader: TemplateLoader {
|
||||
public class FileSystemLoader: Loader {
|
||||
public let paths: [Path]
|
||||
|
||||
public init(paths: [Path]) {
|
||||
|
||||
Reference in New Issue
Block a user