Documentation

You are viewing the documentation for the 2.1.1 release in the 2.1.x series of releases. The latest stable release series is 3.0.x.

§Play 2.0 tips and tricks

§To use Play Framework 2 with Twitter Bootstrap 2:

§Renaming the Bootstrap include files

This can be done with a script like this (run in app/assets/stylesheets/bootstrap)

    for a in *.less; do mv $a _$a; done 
    sed -i 's|@import "|@import "bootstrap/_|' _bootstrap.less 
    mv _bootstrap.less ../bootstrap.less
    sed -i 's|@import "|@import "bootstrap/_|' _responsive.less 
    mv _responsive.less ../bootstrap-responsive.less

§Alternative: using the Build.scala configuration file

    // Only compile the bootstrap bootstrap.less file and any other *.less file in the stylesheets directory
    def customLessEntryPoints(base: File): PathFinder = (
        (base / "app" / "assets" / "stylesheets" / "bootstrap" * "bootstrap.less") +++
        (base / "app" / "assets" / "stylesheets" * "*.less")
    )

Note: this will only compile stylesheets/bootstrap/bootstrap.less and stylesheets/*.less files. If you have any other LESS files in other subdirectories under stylesheets; adjust the function accordingly.

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
        lessEntryPoints <<= baseDirectory(customLessEntryPoints)
    )

§In both cases…

<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/bootstrap/bootstrap.min.css")" />
@iconSpritePath:          "/assets/images/bootstrap/glyphicons-halflings.png";
@iconWhiteSpritePath:     "/assets/images/bootstrap/glyphicons-halflings-white.png";
for i in `ls javascripts/*`; do echo '<script src="@routes.Assets.at("'$i'")"></script>' | sed 's/\.js/.min.js/g'; done

§MongoDB

When using Salat, make sure to disable SQL evolutions in your application.conf via evolutionplugin=disabled or you will run into inexplicable ClassCastExceptions.