johndough
johndough

Reputation: 3

mako access variable outside of code block

I am using Flask and Mako for some templating and was wondering if it is possible to access a defined variable outside of a code block.
In detail I want to do the following:

<%
   foo="bar"
%>
here is foo: ${foo}

the expected output would be:

here is foo: bar

I could not get it working this way, sadly, os I am asking IF this is possible and HOW.
Thanks in advance.

Upvotes: 0

Views: 300

Answers (1)

S.C.A
S.C.A

Reputation: 85

in the mako template I used to do like this, ex:

python code in block

<%
   foo="bar"
%>

javascript code

var foo = "here is foo:"+ "${foo}";
console.log(foo);

Upvotes: 1

Related Questions