Is it possible to assign variables inside a jade file, in order to make the code more readable?
Specifically, I created this jade file:
extends layout
- var format = "%+1.0f"
block title
title Your score table
block body
...
td.utilityUtil #{sprintf(format,value)}
...
And got an error in the last line, that "format" is not defined. Probably I don't assign it correctly, but I didn't find the correct syntax.
P.S. I have Express 3.
You have to declare the variable in the block scope :
extends layout
block title
title Your score table
block body
- var format = "%+1.0f"
...
td.utilityUtil #{sprintf(format,value)}
...