diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f5186c8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -os: - - linux - - osx -language: generic -sudo: required -dist: trusty -osx_image: xcode8 -script: - - eval "$(curl -sL swift.vapor.sh/ci-3.1)" - - eval "$(curl -sL swift.vapor.sh/codecov)" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..97523ae --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Qutheory, LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 046b852..3790462 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,20 @@ -
- -# Leaf - -![Swift](http://img.shields.io/badge/swift-3.0-brightgreen.svg) -[![Build Status](https://travis-ci.org/vapor/core.svg?branch=master)](https://travis-ci.org/vapor/leaf) -[![CircleCI](https://circleci.com/gh/vapor/core.svg?style=shield)](https://circleci.com/gh/vapor/leaf) -[![Code Coverage](https://codecov.io/gh/vapor/core/branch/master/graph/badge.svg)](https://codecov.io/gh/vapor/leaf) -[![Codebeat](https://codebeat.co/badges/a793ad97-47e3-40d9-82cf-2aafc516ef4e)](https://codebeat.co/projects/github-com-vapor-leaf) -[![Slack Status](http://vapor.team/badge.svg)](http://vapor.team) - -Welcome to Leaf. Leaf's goal is to be a simple templating language that can make generating views easier. There's a lot of great templating languages, use what's best for you, maybe that's leaf! The goals of leaf are as follows: - -- Small set of strictly enforced rules -- Consistency -- Parser first mentality -- Extensibility. - -## 📖 Documentation - -Visit the Vapor web framework's [documentation](http://docs.vapor.codes) for instructions on how to use this package. - -## 💧 Community - -Join the welcoming community of fellow Vapor developers in [slack](http://vapor.team). - -## 🔧 Compatibility - -This package has been tested on macOS and Ubuntu. +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/Leaf/Stem+Spawn.swift b/Sources/Leaf/Stem+Spawn.swift
index 9a3e540..624dafa 100644
--- a/Sources/Leaf/Stem+Spawn.swift
+++ b/Sources/Leaf/Stem+Spawn.swift
@@ -19,27 +19,31 @@ extension Stem {
if name.hasPrefix("/") {
name = String(name.characters.dropFirst())
}
-
+ return try spawnLeaf(at: workingDirectory + name)
+ }
+
+ public func spawnLeaf(at path: String) throws -> Leaf {
+ if let existing = cache?[path] {
+ return existing
+ }
+
+ let leaf: Leaf
+
// non-leaf document. rendered as pure bytes
- if name.characters.contains("."), !name.hasSuffix(".leaf") {
- if let existing = cache?[name] { return existing }
- let path = workingDirectory + name
+ if path.components(separatedBy: "/").last?.contains(".") == true, !path.hasSuffix(".leaf") {
let bytes = try Bytes.load(path: path)
let component = Leaf.Component.raw(bytes)
- let leaf = Leaf(raw: bytes.makeString(), components: [component])
- cache(leaf, named: name)
- return leaf
+ leaf = Leaf(raw: bytes.makeString(), components: [component])
+ } else {
+ // add suffix if necessary
+ var path = path
+ path = path.finished(with: SUFFIX)
+
+ let raw = try Bytes.load(path: path)
+ leaf = try spawnLeaf(raw: raw)
}
-
- name = name.finished(with: SUFFIX)
-
- // add suffix if necessary
- if let existing = cache?[name] { return existing }
-
- let path = workingDirectory + name
- let raw = try Bytes.load(path: path)
- let leaf = try spawnLeaf(raw: raw)
- cache(leaf, named: name)
+
+ cache(leaf, named: path)
return leaf
}
diff --git a/circle.yml b/circle.yml
index 094393b..48e37c1 100644
--- a/circle.yml
+++ b/circle.yml
@@ -1,3 +1,11 @@
+dependencies:
+ override:
+ - eval "$(curl -sL https://apt.vapor.sh)"
+ - sudo apt-get install vapor
+ - sudo chmod -R a+rx /usr/
test:
override:
- - eval "$(curl -sL swift.vapor.sh/ci-3.1)"
+ - swift build
+ - swift build -c release
+ - swift test
+
\ No newline at end of file