Skip to content

Navigation Menu

Sign in
Sign up

Document var and special behaviour of toplevel definitions for each scope #1095

Open

Description

  1. Document var

  2. Not just for var, but for val and def:

@val val1 = @{ "value1" }
@if(secondCondition == 1) {
 @val1 // This will also print shadow_value1 even thought it will be defined afterwards
 @val val1 = @{ "shadow_value1" }
 @val1
}

This is because in twirl all @... = (which define a def and does not reassign a var), @var foo =... and @[lazy] val foo ... are moved to the top of the current (pseudo template) (code) block. This is just how twirl works and can not be changed without more or less totally rewriting twirl. So let's document that behaviour. Also see tests, there a lots of example for that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /