Zope Page Templates (ZPT) ========================= This test demonstrates the compilation of TAL and METAL attribute languages. TAL --- :: Namespace elements >>> print render("""\ ... ... Hello, world! ... """) Hello, world! tal:define, tal:attributes, tal:content, tal:replace >>> print render("""\ ...
... ... Hello Universe! ... Hello Universe! ... ...
""")
abcghi Hello World! Hello World!
tal:attributes 'checked' and 'selected' toggles >>> print render("""\ ...
... ... ... ... ...
""")
tal:repeat >>> print render("""\ ...
...

...
...

...
""")

- Item 0)
- Item 1)
- Item 2)
- Item 3)
- Item 4)

tal:repeat (repeat-variable) >>> print render("""\ ...
...

...
...

...
""")

- 0 True
- 1 False
- 2 True

tal:condition >>> print render("""\ ...
...
... Show me! ...
...
... Do not show me! ...
...
""")
Show me!
:: TAL elements with namespace prefix >>> print render("""\ ...
... ... ... ... ... True ...
""")
Hello World! Hello World! Hello World! 0 1 2 True
tal:omit-tag >>> print render("""\ ...
...

No paragraph here.

...

No paragraph here either.

...

A paragraph here.

...
""")
No paragraph here. No paragraph here either.

A paragraph here.

:: Unicode with dynamic attributes and content >>> print render("""\ ...
... ... ... ... ...
""")
<br /> La Peña
:: Using the "string:" expression >>> print render("""\ ...
... ... ...
""", request=object(), greeting=u'Hello')
Hello, world!
:: Using different expressions with try-except operator (|) >>> print render("""\ ...
... ... ...
""")
1 2
:: Using the "structure" TAL pragma. >>> print render("""\ ...
... ...
""")
METAL ----- metal:define-macro, metal:use-macro >>> body = """\ ...
...
... Hello, ! ...
...
...
...
...
""" >>> from chameleon.core.testing import MockTemplate >>> from chameleon.zpt.language import Parser >>> template = MockTemplate(body, Parser()) >>> print render(body, template=template)
Hello, earth!
Hello, world!
metal:define-slot, metal:fill-slot >>> body = """\ ...
...
... Hey, ... a stranger! ...
...
... This will be omitted ... earth! ...
...
...
... earth! ...
...
...
... ...
...
... dummy! ...
...
""" >>> template = MockTemplate(body, Parser()) >>> print render(body, template=template)
Hey, a stranger!
Hey, earth!
Hey, earth!
Hey, a stranger!
Hey, a stranger!
Expression interpolation ------------------------ The ``chameleon.zpt`` parser supports Genshi interpolation expressions. Outside tags: >>> print render("""\ ...
... Interpolation ${'expressions'} are ${'convenient'}. ...
""")
Interpolation expressions are convenient.
Inside tags: >>> print render("""\ ...
... ...
""")