diff --git a/Sources/HummingbirdMustache/Lambda.swift b/Sources/HummingbirdMustache/Lambda.swift index 3d977e9..8072b49 100644 --- a/Sources/HummingbirdMustache/Lambda.swift +++ b/Sources/HummingbirdMustache/Lambda.swift @@ -2,7 +2,8 @@ /// Lambda function. Can add this to object being rendered to filter contents of objects. /// /// See http://mustache.github.io/mustache.5.html for more details on -/// mustache lambdas +/// mustache lambdas. Lambdas work slightly differently in HummingbirdMustache though +/// as they are passed a template representing the contained text and not the raw text /// e.g /// ``` /// struct Object { diff --git a/Sources/HummingbirdMustache/Parser.swift b/Sources/HummingbirdMustache/Parser.swift index 0c92180..640e468 100644 --- a/Sources/HummingbirdMustache/Parser.swift +++ b/Sources/HummingbirdMustache/Parser.swift @@ -261,6 +261,7 @@ extension HBParser { } extension HBParser { + /// context used in parser error public struct Context { public let line: String public let lineNumber: Int diff --git a/Sources/HummingbirdMustache/Template+Parser.swift b/Sources/HummingbirdMustache/Template+Parser.swift index a52292b..550ef85 100644 --- a/Sources/HummingbirdMustache/Template+Parser.swift +++ b/Sources/HummingbirdMustache/Template+Parser.swift @@ -1,14 +1,20 @@ extension HBMustacheTemplate { + /// Error return by `HBMustacheTemplate.parse`. Includes information about where error occurred public struct ParserError: Swift.Error { public let context: HBParser.Context public let error: Swift.Error } + /// Error generated by `HBMustacheTemplate.parse` public enum Error: Swift.Error { + /// the end section does not match the name of the start section case sectionCloseNameIncorrect + /// tag was badly formatted case unfinishedName + /// was not expecting a section end case expectedSectionEnd + /// set delimiter tag badly formatted case invalidSetDelimiter } diff --git a/Sources/HummingbirdMustache/Transform.swift b/Sources/HummingbirdMustache/Transform.swift index 90c99ff..dfbc848 100644 --- a/Sources/HummingbirdMustache/Transform.swift +++ b/Sources/HummingbirdMustache/Transform.swift @@ -1,17 +1,17 @@ -/// Objects that can have a methods run on them. Mustache methods are specific to this implementation +/// Objects that can have a transforms run on them. Mustache transforms are specific to this implementation /// of Mustache. They allow you to process objects before they are rendered. /// -/// The syntax for applying methods is `{{method(variable)}}`. Methods can be applied to both -/// variables and sections. +/// The syntax for applying transforms is `{{method(variable)}}`. Transforms can be applied to both +/// variables, sections and inverted sections. /// /// A simple example would be ensuring a string is lowercase. /// ``` /// {{lowercased(myString)}} /// ``` -/// If applying a method to a sequence then the closing element of the sequence should not include the -/// method name eg +/// If applying a transform to a sequence then the closing element of the sequence should include the +/// transform name eg /// ``` -/// {{#reversed(sequence)}}{{.}}{{\sequence}} +/// {{#reversed(sequence)}}{{.}}{{\reversed(sequence)}} /// ``` public protocol HBMustacheTransformable { func transform(_ name: String) -> Any?