Skip to content

Support for variables #89

Open
Open
@adrianhurt

Description

I've seen there was another issue for this (#63) but it's closed and I think it's an important lack.

For now, if we need to declare some variables we have to to this:

@defining(
  myObject.calcFoo,
  myObject.calcBar
  ) { case (foo, bar) =>
 @defining(myObject.calcResult(foo, bar)) { result =>

  … the whole template …

  }
}

And it's not handy. However, we can declare reusable blocks:

@foo = @{myObject.calcFoo}
@bar = @{myObject.calcBar}
@result = @{myObject.calcResult(foo, bar)}

But they are treated as functions, so foo, bar and result will be recalculated every time. I think every time a reusable block is declared without parenthesis, its value should be calculated once and use it as a variable. So the previous example would define variables, and the following one would define functions.

@foo() = @{myObject.calcFoo}
@bar() = @{myObject.calcBar}
@result() = @{myObject.calcResult(foo, bar)}

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions