HBMustacheTemplate

public final class HBMustacheTemplate

Class holding Mustache template

  • Initialize template

    Throws

    HBMustacheTemplate.Error

    Declaration

    Swift

    public init(string: String) throws

    Parameters

    string

    Template text

  • Render object using this template

    Declaration

    Swift

    public func render(_ object: Any) -> String

    Parameters

    object

    Object to render

    Return Value

    Rendered text

  • Error return by HBMustacheTemplate.parse. Includes information about where error occurred

    See more

    Declaration

    Swift

    public struct ParserError : Swift.Error
  • Error generated by HBMustacheTemplate.parse

    See more

    Declaration

    Swift

    public enum Error : Swift.Error
  • Undocumented

    Declaration

    Swift

    struct ParserState
  • parse mustache text to generate a list of tokens

    Declaration

    Swift

    static func parse(_ string: String) throws -> [Token]
  • parse section in mustache text

    Declaration

    Swift

    static func parse(_ parser: inout HBParser, state: ParserState) throws -> [Token]
  • read until we hit either the start delimiter of a tag or a newline

    Declaration

    Swift

    static func readUntilDelimiterOrNewline(_ parser: inout HBParser, state: ParserState) throws -> String
  • parse variable name

    Declaration

    Swift

    static func parseName(_ parser: inout HBParser, state: ParserState) throws -> (String, String?)
  • Undocumented

    Declaration

    Swift

    static func parseComment(_ parser: inout HBParser, state: ParserState) throws -> String
  • Undocumented

    Declaration

    Swift

    static func parserSetDelimiter(_ parser: inout HBParser, state: ParserState) throws -> ParserState
  • Undocumented

    Declaration

    Swift

    static func readConfigVariable(_ parser: inout HBParser, state: ParserState) throws -> Token?
  • Undocumented

    Declaration

    Swift

    static func hasLineFinished(_ parser: inout HBParser) -> Bool
  • Undocumented

    Declaration

    Swift

    static func isStandalone(_ parser: inout HBParser, state: ParserState) -> Bool
  • Render template using object

    Declaration

    Swift

    func render(context: HBMustacheContext) -> String

    Parameters

    stack

    Object

    context

    Context that render is occurring in. Contains information about position in sequence

    indentation

    indentation of partial

    Return Value

    Rendered text

  • Undocumented

    Declaration

    Swift

    func renderToken(_ token: Token, context: inout HBMustacheContext) -> String
  • Render a section

    Declaration

    Swift

    func renderSection(_ child: Any?, with template: HBMustacheTemplate, context: HBMustacheContext) -> String

    Parameters

    child

    Object to render section for

    parent

    Current object being rendered

    template

    Template to render with

    Return Value

    Rendered text

  • Render an inverted section

    Declaration

    Swift

    func renderInvertedSection(_ child: Any?, with template: HBMustacheTemplate, context: HBMustacheContext) -> String

    Parameters

    child

    Object to render section for

    parent

    Current object being rendered

    template

    Template to render with

    Return Value

    Rendered text

  • Get child object from variable name

    Declaration

    Swift

    func getChild(named name: String, transform: String?, context: HBMustacheContext) -> Any?