would like control over partial extension

43 views
Skip to first unread message

Mark Anderson

unread,
Apr 2, 2016, 5:44:41 PM4/2/16
to mustache.java
Right now, PartialCode has this builtin (and apparently unavoidable) behavior:

    String file = tc.file();

    int dotindex = file.lastIndexOf(".");

    extension = dotindex == -1 ? "" : file.substring(dotindex);


But that doesn't work well for me in my current project, as in some cases my top-level template has a suffix but

none of my partials do.


I'm not sure where the api would go, maybe DefaultMustacheFactory.setExtension(String ext)

so i could do a setExtension(null) if i don't want that behavior.


Thanks.


-mda

Sam Pullara

unread,
Apr 4, 2016, 1:36:55 PM4/4/16
to mustac...@googlegroups.com
You should be able to just override resolvePartialPath() on DefaultMustacheFactory and change it to the behavior you would like. Since there are truly a huge number of requests for configuration options I've gone with instead the ability to override almost any behavior in the system locally through extension. 

In a case like this though, I would probably just suggest you change your partials to have the same extension as the top level mustache template if that is feasible.

Sam

--
You received this message because you are subscribed to the Google Groups "mustache.java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mustachejava...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark D. Anderson

unread,
Apr 4, 2016, 8:20:07 PM4/4/16
to mustac...@googlegroups.com
That suggestion works, thanks.
No chance on changing the extension situation -- for reasons beyond my control the top-level template
and the partials come from two different repositories.
 
-mda
 
Reply all
Reply to author
Forward
0 new messages