Community contributed extensions

ToString Mode

This is NOT a Play specific feature.

Rythm (starts from v1.0.0-20120704) provides an new feature called TSM, the “To String Mode”.

public class Address {
    public String unitNo;
    public String streetNo;
    public String street;
    public String suburb;
    public String state;
    public String postCode;
    // use Rythm.toString() API call
    @Override public String toString() {
        return Rythm.toString("@_.unitNo @_.streetNo @_.street, @_.suburb, @_.state, @_.postCode", this);

Without TSM you will need to declare the type in the template:

return Rythm.render("@args Address _;@_.unitNo @_.streetNo @_.street, @_.suburb, @_.state, @_.postCode", this);

To specify Rythm to render with TSM, use Rythm.toString(...) API instead of Rythm.render(...) API.

Rythm.toString() API

Rythm.toString() API accept 2 parameters:

  1. the template spec, could be either template content, or template file/resource name
  2. an object, usually it’s specified by this keyword

All expressions used inside TSM template starts with _. where “_” means this object.

See also

  1. Auto to string mode
  2. Rythm Manual Home Page