Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-mako
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-mako
Commits
49db3f99
Commit
49db3f99
authored
14 years ago
by
Mike Bayer
Browse files
Options
Downloads
Patches
Plain Diff
- ${} expressions embedded in tags,
such as <%foo:bar x="${...}">, now allow multiline Python expressions.
parent
ae592c70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGES
+4
-0
4 additions, 0 deletions
CHANGES
mako/__init__.py
+1
-1
1 addition, 1 deletion
mako/__init__.py
mako/parsetree.py
+2
-2
2 additions, 2 deletions
mako/parsetree.py
test/test_call.py
+31
-3
31 additions, 3 deletions
test/test_call.py
with
38 additions
and
6 deletions
CHANGES
+
4
−
0
View file @
49db3f99
...
...
@@ -5,6 +5,10 @@
must be referenced explicitly.
[ticket:141]
- ${} expressions embedded in tags,
such as <%foo:bar x="${...}">, now
allow multiline Python expressions.
- Fixed previously non-covered regular
expression, such that using a ${} expression
inside of a tag element that doesn't allow
...
...
This diff is collapsed.
Click to expand it.
mako/__init__.py
+
1
−
1
View file @
49db3f99
...
...
@@ -5,5 +5,5 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
__version__
=
'
0.3.
4
'
__version__
=
'
0.3.
5
'
This diff is collapsed.
Click to expand it.
mako/parsetree.py
+
2
−
2
View file @
49db3f99
...
...
@@ -268,8 +268,8 @@ class Tag(Node):
for
key
in
self
.
attributes
:
if
key
in
expressions
:
expr
=
[]
for
x
in
re
.
split
(
r
'
(\${.+?})
'
,
self
.
attributes
[
key
]):
m
=
re
.
match
(
r
'
^\${(.+?)}$
'
,
x
)
for
x
in
re
.
compile
(
r
'
(\${.+?})
'
,
re
.
S
).
split
(
self
.
attributes
[
key
]):
m
=
re
.
compile
(
r
'
^\${(.+?)}$
'
,
re
.
S
).
match
(
x
)
if
m
:
code
=
ast
.
PythonCode
(
m
.
group
(
1
),
**
self
.
exception_kwargs
)
undeclared_identifiers
=
undeclared_identifiers
.
union
(
...
...
This diff is collapsed.
Click to expand it.
test/test_call.py
+
31
−
3
View file @
49db3f99
from
mako.template
import
Template
from
mako
import
util
import
unittest
from
util
import
result_lines
,
flatten_result
from
test
import
TemplateTest
,
eq_
class
CallTest
(
unittest
.
TestCase
):
class
CallTest
(
TemplateTest
):
def
test_call
(
self
):
t
=
Template
(
"""
<%def name=
"
foo()
"
>
...
...
@@ -44,6 +44,34 @@ class CallTest(unittest.TestCase):
"""
)
assert
result_lines
(
t
.
render
())
==
[
'
foo calling comp1:
'
,
'
this is comp1, 5
'
,
'
foo calling body:
'
,
'
this is the body,
'
,
'
this is comp1, 6
'
,
'
this is bar
'
]
def
test_new_syntax
(
self
):
"""
test foo:bar syntax, including multiline args and expression eval.
"""
t
=
Template
(
"""
<%def name=
"
foo(x, y, q, z)
"
>
${x}
${y}
${q}
${
"
,
"
.join(
"
%s->%s
"
% (a, b) for a, b in z)}
</%def>
<%self:foo x=
"
this is x
"
y=
"
${
'
some
'
+
'
y
'
}
"
q=
"
this
is
q
"
z=
"
${[
(1, 2),
(3, 4),
(5, 6)
]}
"
/>
"""
)
eq_
(
result_lines
(
t
.
render
()),
[
'
this is x
'
,
'
some y
'
,
'
this
'
,
'
is
'
,
'
q
'
,
'
1->2,3->4,5->6
'
]
)
def
test_ccall_caller
(
self
):
t
=
Template
(
"""
<%def name=
"
outer_func()
"
>
...
...
@@ -380,7 +408,7 @@ class CallTest(unittest.TestCase):
"""
)
assert
result_lines
(
t
.
render
())
==
[
'
this is a
'
,
'
this is b
'
,
'
this is c:
'
,
"
this is the body in b
'
s call
"
,
'
the embedded
"
d
"
is:
'
,
'
this is d
'
]
class
SelfCacheTest
(
unittest
.
TestCase
):
class
SelfCacheTest
(
TemplateTest
):
"""
this test uses a now non-public API.
"""
def
test_basic
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment