• Like
  • Save
Intro to TAL
Upcoming SlideShare
Loading in...5
×
 

Intro to TAL

on

  • 2,588 views

An introductory lesson to the Zope page templating language.

An introductory lesson to the Zope page templating language.

Statistics

Views

Total Views
2,588
Views on SlideShare
2,588
Embed Views
0

Actions

Likes
0
Downloads
17
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Intro to TAL Intro to TAL Presentation Transcript

    • PLONE SYMPOSIUM EAST 2011Intro to TALChrissy Wainwright
    • What is TAL? PLONE SYMPOSIUM EAST 2011* Zope Templating Language* Allow for dynamic content in HTML* Does not render in the site
    • TAL Syntax PLONE SYMPOSIUM EAST 2011<div tal:content=”context/Title”></div><tal:title content=”context/Title” />Use an HTML tag or <tal:whatever...
    • TAL Syntax PLONE SYMPOSIUM EAST 2011<a tal:attributes=”href url; class linkClass”>* separate multiple declarations with a semicolon* align variables/attributes on the left
    • TAL Syntax PLONE SYMPOSIUM EAST 2011<div tal:condition=”python:phone and fax”>Python expressions allow us to put Python codedirectly in the template. This is not meant forlong, complex expressions.
    • TAL Syntax PLONE SYMPOSIUM EAST 2011<a tal:attributes= ”href string:${item/url}/folder”>With string expressions, we can add static text todynamic content or combine multiple variables
    • TAL Commands PLONE SYMPOSIUM EAST 2011* define* condition* repeat* content/replace* attributes* omit-tag
    • tal:define PLONE SYMPOSIUM EAST 2011* defines variables<div id=”portal-breadcrumbs” tal:define=”breadcrumbs view/breadcrumbs”>
    • tal:condition PLONE SYMPOSIUM EAST 2011* evaluates an expression* display element if True* omit element if False
    • tal:condition PLONE SYMPOSIUM EAST 2011<tal:item define=”is_last repeat/crumb/end”> <span tal:condition=”not: is_last”> This </span> <span tal:condition=”is_last”> That </span></tal:item>
    • tal:repeat PLONE SYMPOSIUM EAST 2011* repeats over a set of elements* available variables: * index / number * even / odd * start / end * length
    • tal:repeat PLONE SYMPOSIUM EAST 2011<span tal:repeat=”crumb breadcrumbs”> <a tal:attributes=”href crumb/absolute_url” tal:content=”crumb/Title”>crumb</a></span>
    • tal:content PLONE SYMPOSIUM EAST 2011* determines what content will display inside a tag* any content inside the tag in the template will not display in the site<span tal:content=”title”>The Title</span>
    • tal:content PLONE SYMPOSIUM EAST 2011use ‘structure’ for content with HTML code,so the code is not rendered as text<tal:body content=”structure context/getText” />
    • tal:replace PLONE SYMPOSIUM EAST 2011* determines what content will display in place of a tag* the tag will not display in the site<span tal:replace=”title”>The Title</span>
    • tal:replace PLONE SYMPOSIUM EAST 2011* replacing an element with ‘nothing’ will not render in the site* good for commenting out parts of the code<div tal:replace=”nothing”> This is a comment</div>
    • tal:attributes PLONE SYMPOSIUM EAST 2011allows you to set a dynamic value to an attribute(href, src, class, etc)<a href=”#” tal:content=”crumb/Title” tal:attributes=”href crumb/absolute_url”></a>
    • tal:omit-tag PLONE SYMPOSIUM EAST 2011* similar to condition, evaluates an expression* if true, the wrapping tag is omitted, and only the content is displayed* if false, the tag displays* omit-tag=”” will also omit the tag
    • tal:omit-tag PLONE SYMPOSIUM EAST 2011<a href=”#” tal:define=”url crumb/absolute_url” tal:omit-tag=”not:url” tal:attributes=”href url”>
    • Macros PLONE SYMPOSIUM EAST 2011The Macro Expansion Template AttributeLanguage (METAL) allows us to create macroswithin our page templates, which saves us fromrepeating code.* define-macro / use-macro* define-slot / fill-slot
    • Macros PLONE SYMPOSIUM EAST 2011<div metal:define-macro=”footer”> &copy; 2011 Company Name</div><metal:foot use-macro=”context/my_macros/macros/footer”></metal:foot>
    • Macro Slots PLONE SYMPOSIUM EAST 2011<h1 metal:define-slot=”content-title”> <span tal:replace=”context/Title”></span></h1><h1 metal:fill-slot=”content-title”> Custom Title</h1>
    • PLONE SYMPOSIUM EAST 2011 eck outCh p. com/d emossix feetu