"When using tags, the values of the arguments are taken as literal strings by default. To embed Python expressions as arguments, use the embedded expression format"
If you need to access caller, you can all use the `call` format `<%call`
If you don't, I prefer the expression format `${fh.form(vars)}`
mako.exceptions.SyntaxException: (SyntaxError) keyword can't be an expression (<unknown>, line 1) ("dict('class'='dfdf')") in filemako.exceptions.SyntaxException: (SyntaxError) keyword can't be an expression (<unknown>, line 1) ("dict('cxx'='sdfdf')") in fileHi,I think we are deviating from the main issue. Lets use any other dictionary {'cxx':'sdfdf'}
<%fh:form action="something", method="POST" , formactions="${dict('cxx'='sdfdf')}">
</%fh:form>but the error remains the samemako.exceptions.SyntaxException: (SyntaxError) keyword can't be an expression (<unknown>, line 1) ("dict('cxx'='sdfdf')") in file
Srikanth
< br />
On Friday, March 18, 2016 at 7:25:07 PM UTC-5, Srikanth Bemineni wrote:
Hi ,
I have been struggling for good examples on how to pass dictionary to a def. None of the MAKO documentation shows how to pass dictionary values to defs or blocks
<%def name="form(action,method,formoptions)">
<%
attributeset = ""
attributeset += 'action="' + action.strip() +'" '
attributeset += 'method="' + method.strip() +'" '
for (key,value) in formoptions.items():
attributeset += key.strip() + '="' + value.strip() + '" '
%>
//some cool typography stuff
<form ${attributeset}> ${caller.body()}
</form>
</%def>
In other file.
<%namespace name="fh" file="form.mako"/>
<%fh:form action="something", method="POST" , formactions={????}>
</%fh:form>
what are different ways to pass a dictionary ?
Srikanth Bemineni
I think we are deviating from the main issue. Lets use any other dictionary {'cxx':'sdfdf'}<%fh:form action="something", method="POST" , formactions="${dict('cxx'='sdfdf')}">
</%fh:form>