[Template] Initialisers to throw on failure
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
PODS:
|
||||
- PathKit (0.4.0)
|
||||
- PathKit (0.5.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- PathKit (~> 0.4.0)
|
||||
- PathKit (~> 0.5.0)
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
PathKit: bfbf544223c1a9fbf5dd7ff301d9ab1c46603b7d
|
||||
PathKit: 64e70cb924d6faed9251049f5f28662855524baf
|
||||
|
||||
COCOAPODS: 0.38.2
|
||||
|
||||
@@ -11,6 +11,6 @@ Pod::Spec.new do |spec|
|
||||
spec.ios.deployment_target = '8.0'
|
||||
spec.osx.deployment_target = '10.9'
|
||||
spec.requires_arc = true
|
||||
spec.dependency 'PathKit', '~> 0.4.0'
|
||||
spec.dependency 'PathKit', '~> 0.5.0'
|
||||
end
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ public class Template {
|
||||
public let parser:TokenParser
|
||||
|
||||
/// Create a template with the given name inside the main bundle
|
||||
public convenience init?(named:String) throws {
|
||||
public convenience init(named:String) throws {
|
||||
try self.init(named:named, inBundle:nil)
|
||||
}
|
||||
|
||||
/// Create a template with the given name inside the given bundle
|
||||
public convenience init?(named:String, inBundle bundle:NSBundle?) throws {
|
||||
public convenience init(named:String, inBundle bundle:NSBundle?) throws {
|
||||
var url:NSURL?
|
||||
|
||||
if let bundle = bundle {
|
||||
@@ -25,13 +25,12 @@ public class Template {
|
||||
|
||||
/// Create a template with a file found at the given URL
|
||||
public convenience init(URL:NSURL) throws {
|
||||
let templateString = try NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding)
|
||||
self.init(templateString: templateString as String)
|
||||
try self.init(path: Path(URL.absoluteString))
|
||||
}
|
||||
|
||||
/// Create a template with a file found at the given path
|
||||
public convenience init?(path:Path) throws {
|
||||
self.init(templateString: path.read() ?? "")
|
||||
public convenience init(path:Path) throws {
|
||||
self.init(templateString: try path.read())
|
||||
}
|
||||
|
||||
/// Create a template with a template string
|
||||
|
||||
Reference in New Issue
Block a user