Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
d87a1107
Commit
d87a1107
authored
Mar 16, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change tal:insert to tal:content.
Also slightly refactored the starttag optimization code.
parent
236ef253
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
17 deletions
+22
-17
lib/python/TAL/TALDefs.py
lib/python/TAL/TALDefs.py
+2
-2
lib/python/TAL/TALGenerator.py
lib/python/TAL/TALGenerator.py
+20
-15
No files found.
lib/python/TAL/TALDefs.py
View file @
d87a1107
...
...
@@ -104,7 +104,7 @@ KNOWN_METAL_ATTRIBUTES = [
KNOWN_TAL_ATTRIBUTES
=
[
"define"
,
"condition"
,
"
inser
t"
,
"
conten
t"
,
"replace"
,
"repeat"
,
"attributes"
,
...
...
@@ -138,7 +138,7 @@ def parseAttributeReplacements(arg):
def parseSubstitution(arg):
m = _subst_re.match(arg)
if not m:
print "
Bad
syntax
in
insert
/
replace
:
", `arg`
print "
Bad
syntax
in
replace
/
content
:
", `arg`
return None, None
key, expr = m.group(1, 2)
if not key:
...
...
lib/python/TAL/TALGenerator.py
View file @
d87a1107
...
...
@@ -128,12 +128,12 @@ class TALGenerator:
if
item
[
0
]
==
"endTag"
:
collect
.
append
(
"</%s>"
%
item
[
1
])
continue
if
item
[
0
]
==
"startTag"
and
not
item
[
2
]
:
collect
.
append
(
"<%s>"
%
item
[
1
])
continue
if
item
[
0
]
==
"startEndTag"
and
not
item
[
2
]
:
collect
.
append
(
"<%s/>"
%
item
[
1
])
continue
if
item
[
0
]
==
"startTag"
:
if
self
.
optimizeStartTag
(
collect
,
item
[
1
],
item
[
2
],
">"
):
continue
if
item
[
0
]
==
"startEndTag"
:
if
self
.
optimizeStartTag
(
collect
,
item
[
1
],
item
[
2
],
"/>"
):
continue
text
=
string
.
join
(
collect
,
""
)
if
text
:
output
.
append
((
"rawtext"
,
text
))
...
...
@@ -143,6 +143,11 @@ class TALGenerator:
collect
=
[]
return
output
def
optimizeStartTag
(
self
,
collect
,
name
,
attrlist
,
end
):
if
not
attrlist
:
collect
.
append
(
"<%s%s"
%
(
name
,
end
))
return
1
def
todoPush
(
self
,
todo
):
self
.
todoStack
.
append
(
todo
)
...
...
@@ -299,7 +304,7 @@ class TALGenerator:
fillSlot = metaldict.get("
fill
-
slot
")
defines = taldict.get("
define
")
condition = taldict.get("
condition
")
insert = taldict.get("
inser
t
")
content = taldict.get("
conten
t
")
replace = taldict.get("
replace
")
repeat = taldict.get("
repeat
")
attrsubst = taldict.get("
attributes
")
...
...
@@ -311,11 +316,11 @@ class TALGenerator:
if n > 1:
raise METALError("
only
one
METAL
attribute
per
element
")
n = 0
if
inser
t: n = n+1
if
conten
t: n = n+1
if replace: n + n+1
if repeat: n = n+1
if n > 1:
raise TALError("
can
't use
inser
t, replace, repeat together")
raise TALError("
can
't use
conten
t, replace, repeat together")
repeatWhitespace = None
if repeat:
# Hack to include preceding whitespace in the loop program
...
...
@@ -340,8 +345,8 @@ class TALGenerator:
if condition:
self.pushProgram()
todo["condition"] = condition
if
inser
t:
todo["
insert"] = inser
t
if
conten
t:
todo["
content"] = conten
t
elif replace:
todo["replace"] = replace
self.pushProgram()
...
...
@@ -356,7 +361,7 @@ class TALGenerator:
else:
repldict = {}
self.emitStartTag(name, self.replaceAttrs(attrlist, repldict))
if
inser
t:
if
conten
t:
self.pushProgram()
self.todoPush(todo)
...
...
@@ -366,9 +371,9 @@ class TALGenerator:
# Shortcut
self.emitEndTag(name)
return
insert = todo.get("inser
t")
if
inser
t:
self.emitSubstitution(
inser
t)
content = todo.get("conten
t")
if
conten
t:
self.emitSubstitution(
conten
t)
self.emitEndTag(name)
repeat = todo.get("repeat")
if repeat:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment