Include static file in Play 2.4 template

I am using the Play platform.

You can include the following in your template: css.

    <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">

      

But what I would like to do is include the css directly on the webpage

<style>@[include the static file contents]</style>

      

Is it possible?

+3


source to share


1 answer


As mentioned, this is the preferred NOT way , as you can use the generic 'tags technique for this,

just create a file views/tags/yourStyles.scala.html

with content:

<style>
    * {
        background: orange;
    }
</style>

      



so in your template / view you can use it like (sample):

<head>
    <title>@title</title>
    <link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/main.css")">
    <link rel="shortcut icon" type="image/png" href="@routes.WebJarAssets.at("images/favicon.png")">
    @tags.yourStyles() <!-- <-here ->
</head>

      

+4


source







All Articles