Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of local variables in the template #5

Open
denis-itskovich opened this issue Jun 15, 2015 · 2 comments
Open

Usage of local variables in the template #5

denis-itskovich opened this issue Jun 15, 2015 · 2 comments

Comments

@denis-itskovich
Copy link

Can local variables be defined and used in the template?

I tried to use template as simple as following:

@a = 1
@a

and expected that the produced output will be 1, but it failed with the error: NameError: global name 'a' is not defined

Locally, I added a unit test, reproducing this issue:

def testSimpleLocalVariable(self):
  self.assertEquals("1", pyrazor.Render("@a=1\n@a\n"))

Am I missing something?

@denis-itskovich denis-itskovich changed the title [Question] usage of local variables in the template Usage of local variables in the template Jun 15, 2015
@luscoma
Copy link
Owner

luscoma commented Jan 14, 2018

Probably a bit late now but you could probably do

@:
a = 1
@A

Creating inline support would need to be added.

@Yeganloo
Copy link
Contributor

The usage is wrong!
when you wrote @a = 1 it's equal to @(a) = 1.
"= 1" is text and "a" is a local variable.
what you actually needs is @(a = 1) and pyrazor do not support parenthesis yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants