anoopelias
anoopelias

Reputation: 9548

Template routing using routes in Play 2.0 & scala

Is it possible to route directly to a template using the routes file?

I am looking for an entry like this,

GET     /template/main/*param           views.html.main(param)

or something similar. Currently I am forwarding to an action to fetch the template.

Edit: Indicated param as well, so that the requirement is clear.

Upvotes: 0

Views: 551

Answers (3)

hiamex
hiamex

Reputation: 315

If you have scala dynamic templates you need a controller for serve them and call in it a template.render() method, so it renders to html.

Upvotes: 1

Jakob
Jakob

Reputation: 749

Use some other web framework that will suit your needs better. It seems you use Play but dont really want to since you want to do things not intended to be done by Play...

Upvotes: 0

gre
gre

Reputation: 1841

If you want to directly route an URL to a template, then it's not a template but a static HTML file. You can have it in "/public/..." but, I don't know if it's possible to have it somewhere else.

Otherwise, you can still just have one line of code in the controller:

def myAction = Action(Ok(views.html.main.render()))

Upvotes: 1

Related Questions