webjars / webjars-play

MIT License
80 stars 34 forks source link

Assets.versioned instead of Assets.at #44

Open muuki88 opened 10 years ago

muuki88 commented 10 years ago

Webjars-play only supports the Assets.at route (located in the nastyReflection).

If I have an assets route like this

GET    /assets/file     controllers.Assets.versioned(path="public", file: Asset)

Results in an InvocationTargetException, because the at method is not there.

jamesward commented 10 years ago

I think that I might just remove that functionality because it is pretty brittle. Here is what you can use instead:

    <script>
        @play.api.Play.current.configuration.getString("assets.url").fold {
            @Html(org.webjars.RequireJS.getSetupJavaScript(routes.WebJarAssets.at("").url))
        } { assetsUrl =>
            @Html(org.webjars.RequireJS.getSetupJavaScript(StaticWebJarAssets.url(""), routes.WebJarAssets.at("").url))
        }
    </script>
    <script data-main="@routes.Assets.versioned("javascripts/app.js")" src="@StaticWebJarAssets.url(WebJarAssets.locate("require.min.js"))"></script>

From: https://github.com/jamesward/salesforce-webhook-creator/blob/master/app/views/app.scala.html

LMKWYT