java - Play 2.5 - Storing Templates in a Database -


i'm using play 2.5 , there requirement store of relevant static html template data in column in database can call , pass relevant object into.

this proving difficult seems play requires template exist static files included in classpath prior running.

for example, have index.scala.html file looks this:

<html> hello @name! </html> 

i want store template in variable (i.e. string template) can pass objects so:

string template = greetingdto.gettemplate();  content html = template.render(user.getname()); 

this do regarding templating @ point. need format passed in objects user-editable html layout e-mail notifications.

is possible without hacking around play's classpath structure? begin this? possible achieve easier using different template engine twirl. example have found this old freemarker post several years ago hoping there might little more current.

you won't able use twirl, default template engine, because compiled scala code , bytecodes , happens @ compile/build time. the docs:

templates compiled standard scala functions, following simple naming convention. if create views/application/index.scala.html template file, generate views.html.application.index class has apply() method.

of course, possible change template engine , can use template engine better fits requirements (dynamically load , parse templates). finally, take @ modules directory.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -