Using a variable as partial?

339 views
Skip to first unread message

Matthieu Legras

unread,
Jul 20, 2011, 6:19:13 AM7/20/11
to mustache.java
Hi there,

Is it possible with mustache to use a variable as the name of a
partial? I'd like to do something like:

{{>{{foobar}} }}

Thanks!

Matthieu

Sam

unread,
Jul 20, 2011, 12:30:36 PM7/20/11
to mustache.java
This isn't supported. However, you could override the partial
resolution method by setting a custom superclass and implement
something like what you describe but you'd end up with a pretty non-
standard implementation. You might instead use regular replacement and
use another MustacheBuilder to create the content, something like:

Mustache:
{{foobar}}

Backing code:
public FutureWriter foobar() {
// Use mustache builder API to grab the partial you need
return the furture writer;
}

Sam

On Jul 20, 3:19 am, Matthieu Legras <matthieu.leg...@spotuse.com>
wrote:

Matthieu Legras

unread,
Jul 21, 2011, 6:51:57 AM7/21/11
to mustac...@googlegroups.com
Thanks for the answer!
Reply all
Reply to author
Forward
0 new messages