Community contributed extensions

PlayRythm module documentation

Welcome to PlayRythm module documentation. This documentation is intended for the 1.0.0-20121210 release and might be significantly differ from previous module version’s documentation.

Check the version history.

PlayRythm features

PlayRythm is yet another template engine plugin for Play!Framework 1.2x version:

  1. Static and strong typed pure Java template. Yes it’s like Japid and Jamon
  2. Razor like syntax
  3. Easy to integrate with Play and migrate your groovy template one by one
    1. Your existing controllers doesn’t need to be changed
    2. Your existing mailers doesn’t need to be changed
    3. Once an new template file under app/rythm folder created in the corresponding path, Rythm will take over; all other groovy templates still works
    4. Great Error reporting on parsing, compilation and excuting errors, using Play-2.0 style!
  4. Automatic escape expression output, like Groovy and unlike Japid
  5. High performance at Japid level
  6. Support layout and tag, you get all you have in Groovy template, actually even more
  7. (Play specific) Support FastTags and JavaExtensions with constraints
  8. (Play specific) Support properties enhancement to template class
  9. Tag invocation decorations and chain them together
  10. Template content decorations and chain them together
  11. (Play specific) Invoke controller action method directly from within your template
  12. Include other template inline (not the same as tag invocation)
  13. (Play specific) New Cache4 annotation to mark on controller action method
  14. (Play specific) Support GAE and other PaaS like Heroku
  15. String Interpolation Mode
  16. ToString Mode

There is a live demo app running on GAE for your reference

Template Syntax at a glance

Based on Rythm template engine, PlayRythm module provides an easy to read/write template language which is very like that is used in .Net MVC’s Razor template engine. Here is one rythm template example:

@args List<User> users
@for(User user: users) {
    @if (!user.disabled()) {
        <li class="@user_parity">
            <a href="@url(">@user.getName()</a>

Use PlayRythm template engine (Play specific)

1. Add PlayRythm into your conf/dependencies.yml file:

# Application dependencies
       - play -> rythm

Don’t forget run play deps --sync to download rythm module after you updated your conf/dependencies.yml file

2. Create the template file in app/rythm folder.

The layout of the folder should be the same as your app/views folder.

Rythm can stay with your groovy templates. Suppose you have a controller action Application.index(), if you have Application/index.html file put into app/rythm folder, then Rythm template engine will execute it. If not then your Application/index.html file in app/views folder will be picked up and processed by Groovy template engine. Please refer to Integration Guide for more information

See Also

  1. Integrate PlayRythm into your Play project
  2. User's guide
  3. Reference manual
  4. String interpolation mode
  5. To string mode
  6. Auto to string mode