You are viewing the documentation for the 2.4.x release series. The latest stable release series is 2.5.3.

§Using CoffeeScript

CoffeeScript is a small and elegant language that compiles into JavaScript. It provides a nice syntax for writing JavaScript code.

Compiled assets in Play must be defined in the app/assets directory. They are handled by the build process and CoffeeScript sources are compiled into standard JavaScript files. The generated JavaScript files are distributed as standard resources into the same public/ folder as other unmanaged assets, meaning that there is no difference in the way you use them once compiled.

For example a CoffeeScript source file app/assets/javascripts/ will be available as a standard JavaScript resource, at public/javascripts/main.js.

CoffeeScript sources are compiled automatically during an assets command, or when you refresh any page in your browser while you are running in development mode. Any compilation errors will be displayed in your browser:


Here is an example layout for using CoffeeScript in your projects:

 └ assets
    └ javascripts

You can use the following syntax to use the compiled JavaScript file in your template:

<script src=""javascripts/main.js")">

§Enablement and Configuration

CoffeeScript compilation is enabled by simply adding the plugin to your plugins.sbt file when using the PlayJava or PlayScala plugins:

addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")

The plugin’s default configuration is normally sufficient. However please refer to the plugin’s documentation for information on how it may be configured.

Next: Using LESS CSS

Dokümantasyonun bu çevirisi Play ekibi tarafından yapılmamaktadır. Eğer bir hata bulduysanız, bu sayfanın kaynak kodu burada bulunmaktadır. Dokümantasyon yönergelerini okuduktan sonra lütfen katkı yapmaktan çekinmeyin.