having a 'override' directory for Twirl templates - how to??

17 views
Skip to first unread message

Ian Holsman

unread,
Jun 19, 2017, 1:52:06 PM6/19/17
to play-fr...@googlegroups.com

Hi.
i'm trying to create a way to override templates so that someone can over a template or two by placing a template or two in a directory (say internal/views ) 
and have the app start using those instead of the ones in app/views.

the aim is for me to build a 'generic' version of my tool (and putting it in opensource), while at the same time putting custom templates in a different directory and having the app use those.

I spoke to Will on gitter, and he mentioned jar files and stuff, but I think what i'd like to be able to do is have them both available to edit/change at the same time.

I thought it may be easy to do this in SBT via something like


//TwirlKeys.compileTemplates += baseDirectory.value / "internal"
val internalDir = baseDirectory / "internal"

sourceDirectories in (Compile, TwirlKeys.compileTemplates) := (unmanagedSourceDirectories in Compile).value ++ internalDir.value

but that doesn't compile.

any suggestions ?


--

Ian Holsman

unread,
Jun 21, 2017, 10:47:56 AM6/21/17
to play-fr...@googlegroups.com
so as an update. I have managed to get a second area to compile
by adding the following in build.sbt (thanks @igmar) 
sourceDirectories in (Compile,TwirlKeys.compileTemplates)  ++= Seq(baseDirectory.value / "internal")

but it still doesn't do exactly what I need it to do. It will now grab the templates from both places, but I would like it to just take the one from internal if it's there, instead of being a random chance on which was last compiled which seems to be happening now

Reply all
Reply to author
Forward
0 new messages