Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
fix issue mwunsch#49
Browse files Browse the repository at this point in the history
  • Loading branch information
tomatohf committed Apr 8, 2015
1 parent 74df673 commit f5833d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ trait HelperOptions[T] {
*/
def inverse(binding: Binding[T], extraData: Map[String, Binding[T]]): String

def hasInverse: Boolean

/**
* Look up a path in the the current context. The one in which the helper was called.
* @param path The path to lookup in the context. e.g., ../name
Expand Down Expand Up @@ -111,6 +113,8 @@ class HelperOptionsBuilder[T](context: Context[T],
}
}

val hasInverse = inverseNode.isDefined

def lookup(path: String): Binding[T] = {
HandlebarsGrammar.path(path).map { identifier =>
context.lookup(identifier, Seq()).binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class IfHelper[T] extends Helper[T] with Loggable {
if (options.argument(0).isTruthy)
options.visit(binding)
else
options.inverse(binding)
if (options.hasInverse) options.inverse(binding)
else ""
}
}

0 comments on commit f5833d8

Please sign in to comment.