Echo tag

{% echo <expr> %}
{{ <expr> }}

The echo tag simply outputs the evaluation of the given expression. See the Expressions section for details on how expressions are evaluated.

Note that {{ <expr> }} is just a shortcut for {% echo <expr> %}.

Examples

First, let's assume we have the follow code to render the template set up:

  CarrotEngine engine = new CarrotEngine();
  engine.getConfig().setResourceLocator(...);

  Bindings bindings = new MapBindings(ImmutableMap.<String, Object>builder()
      .put("num", 5463)
      .put("str", "Hello, World")
      .put("user", ImmutableMap.of(
          "id", 1234,
          "name", "Dean"))
      .put("details", ImmutableMap.of(
          1234, "Some details.")
      .build());

  System.out.println(engine.process("filename.html", bindings));

Given the following template:

  A number: {% echo num %}
  A string: {% echo str %}
  A user: {% echo user.id %} {% echo user.name %}
  User's details: {% echo details[user.id] %}

You'll get the following output:

  A number: 5463
  A string: Hello, World
  A user: 1234 Dean
  User's details: Some details.

Things to note: