refactor(loader): Rename TemplateLoader to Loader

This commit is contained in:
Kyle Fuller
2016-11-28 18:25:38 +00:00
parent c59b263446
commit c99a40c5d9
4 changed files with 8 additions and 10 deletions

View File

@@ -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

View File

@@ -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")
}

View File

@@ -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")
}

View File

@@ -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]) {