Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Playframework2, how to serve multiple asset directory?

There are two asset directory, one is /ui/dist and the other is /public. I tried to write the routes like this:

GET            /assets/*file                        controllers.Assets.at(path="/public", file)
GET     /ui/*file               controllers.Assets.at(path="/ui/dist", file)

But it will throws an error while compiling:

[error] Unspecified value parameter file.
[error]         <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">

Does anyone have ideas about how to solve this...

like image 736
Hanfei Sun Avatar asked Sep 28 '22 14:09

Hanfei Sun


1 Answers

I found the key is to pass in another parameter to routes.Assets.at, the following is from the playframework Asset document

GET  /javascripts/*file        Assets.at("public/javascripts", file)
GET  /images/*file             Assets.at("public/images", file)

Then you will need to specify both parameters when using the reverse router:

<script src="@routes.Assets.at("public/javascripts", "jquery.js")"></script>
<image src="@routes.Assets.at("public/images", "logo.png")">
like image 183
Hanfei Sun Avatar answered Oct 06 '22 02:10

Hanfei Sun