Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (30 sloc) 869 Bytes
package tipi.core
import scala.util.parsing.combinator._
import scala.util.parsing.input._
case class Tipi(
val simpleTagStart: String = "{{",
val simpleTagEnd: String = "}}",
val blockStart: String = "#",
val blockEnd: String = "/",
val globalEnv: Env = Env.Basic
) {
val parse = Parser(
simpleTagStart = simpleTagStart,
simpleTagEnd = simpleTagEnd,
blockStart = blockStart,
blockEnd = blockEnd
)
val expand = Expand
val render = Render
def apply(input: io.Source): Either[String,String] = {
apply(input.mkString)
}
def apply(inputString: String): Either[String,String] = {
parse(new CharSequenceReader(inputString)) match {
case parse.Success(doc, _) =>
Right(render(expand((globalEnv, doc))))
case err: parse.NoSuccess =>
Left(err.toString)
}
}
}
Something went wrong with that request. Please try again.