mwunsch / handlebars.scala

A Scala implementation of the Handlebars templating language (a superset of Mustache).
Apache License 2.0
112 stars 40 forks source link

Handlebars.apply on empty string results in parse error #36

Closed williamho closed 10 years ago

williamho commented 10 years ago

If you pass an empty string to Handlebars.apply, it results in a parse error:

scala> import com.gilt.handlebars.Handlebars
import com.gilt.handlebars.Handlebars

scala> Handlebars("")
java.lang.RuntimeException: Could not parse template:

scala.util.parsing.input.CharSequenceReader@673c8b91
        at scala.sys.package$.error(package.scala:27)
        at com.gilt.handlebars.parser.ProgramHelper$$anonfun$programFromString$1.apply(ProgramHelper.scala:12)
        at com.gilt.handlebars.parser.ProgramHelper$$anonfun$programFromString$1.apply(ProgramHelper.scala:12)
        at scala.util.parsing.combinator.Parsers$ParseResult.getOrElse(Parsers.scala:123)
        at com.gilt.handlebars.parser.ProgramHelper$class.programFromString(ProgramHelper.scala:11)
        at com.gilt.handlebars.DefaultHandlebarsBuilder$.programFromString(HandlebarsBuilder.scala:32)
        at com.gilt.handlebars.DefaultHandlebarsBuilder$.apply(HandlebarsBuilder.scala:34)
        at com.gilt.handlebars.Handlebars$.createBuilder(Handlebars.scala:40)
        at com.gilt.handlebars.Handlebars$.apply(Handlebars.scala:37)