SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
PLONE SYMPOSIUM EAST 2011




Intro to TAL
Chrissy 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 code
directly in the template. This is not meant for
long, complex expressions.
TAL Syntax
                                           PLONE SYMPOSIUM EAST 2011




<a tal:attributes=
  ”href string:${item/url}/folder”>

With string expressions, we can add static text to
dynamic 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 2011




use ‘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 2011




allows 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 2011




The Macro Expansion Template Attribute
Language (METAL) allows us to create macros
within our page templates, which saves us from
repeating 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 out
Ch
             p. com/d emos
six feetu

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (9)

Develop advance joomla! MVC Component for version 3
Develop advance joomla! MVC Component for version 3Develop advance joomla! MVC Component for version 3
Develop advance joomla! MVC Component for version 3
 
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
 
Building YAP Applications with YUI
Building YAP Applications with YUIBuilding YAP Applications with YUI
Building YAP Applications with YUI
 
Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress Way
 
State of play for Joomla - Nov 2014
State of play for Joomla - Nov 2014State of play for Joomla - Nov 2014
State of play for Joomla - Nov 2014
 
Joomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesJoomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic Templates
 
Upgrading a Plone 3 Theme for Plone 4: Beyond the Basics
Upgrading a Plone 3 Theme for Plone 4: Beyond the BasicsUpgrading a Plone 3 Theme for Plone 4: Beyond the Basics
Upgrading a Plone 3 Theme for Plone 4: Beyond the Basics
 
Joomla! Day UK 2009 Menus Presentation
Joomla! Day UK 2009 Menus PresentationJoomla! Day UK 2009 Menus Presentation
Joomla! Day UK 2009 Menus Presentation
 
WPtech: L'API Customizer pour les plugins
WPtech: L'API Customizer pour les pluginsWPtech: L'API Customizer pour les plugins
WPtech: L'API Customizer pour les plugins
 

Andere mochten auch

Unknown plone
Unknown ploneUnknown plone
Unknown plone
cdw9
 
Anne’s photos
Anne’s photosAnne’s photos
Anne’s photos
adaly2
 
Human papillomavirus hpv_ (1)
Human papillomavirus hpv_ (1)Human papillomavirus hpv_ (1)
Human papillomavirus hpv_ (1)
HughMcCullough14
 

Andere mochten auch (10)

The Future of [Plone] Theming
The Future of [Plone] ThemingThe Future of [Plone] Theming
The Future of [Plone] Theming
 
Funnelweb ploneconf2010
Funnelweb ploneconf2010Funnelweb ploneconf2010
Funnelweb ploneconf2010
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developers
 
Unknown plone
Unknown ploneUnknown plone
Unknown plone
 
Anne’s photos
Anne’s photosAnne’s photos
Anne’s photos
 
Human papillomavirus hpv_ (1)
Human papillomavirus hpv_ (1)Human papillomavirus hpv_ (1)
Human papillomavirus hpv_ (1)
 
Welcome to my University of Oregon
Welcome to my University of OregonWelcome to my University of Oregon
Welcome to my University of Oregon
 
Bcs
BcsBcs
Bcs
 
The eggless Plone manifesto (or Plone the open source cms-as-a-service platf...
The eggless Plone manifesto (or Plone  the open source cms-as-a-service platf...The eggless Plone manifesto (or Plone  the open source cms-as-a-service platf...
The eggless Plone manifesto (or Plone the open source cms-as-a-service platf...
 
Managing Chaos: Merging 120 Sites into a single Plone Multisite Solution
Managing Chaos: Merging 120 Sites into a single Plone Multisite SolutionManaging Chaos: Merging 120 Sites into a single Plone Multisite Solution
Managing Chaos: Merging 120 Sites into a single Plone Multisite Solution
 

Ähnlich wie Intro to TAL

Php Mysql Feedrss
Php Mysql FeedrssPhp Mysql Feedrss
Php Mysql Feedrss
RCS&RDS
 
WDIM268 Week 6 (Summer 2010)
WDIM268 Week 6 (Summer 2010)WDIM268 Week 6 (Summer 2010)
WDIM268 Week 6 (Summer 2010)
Tyler Sticka
 
Xhtml Css Presentation
Xhtml Css PresentationXhtml Css Presentation
Xhtml Css Presentation
joshpuckett
 

Ähnlich wie Intro to TAL (20)

New Browsers
New BrowsersNew Browsers
New Browsers
 
Transforming Xml Data Into Html
Transforming Xml Data Into HtmlTransforming Xml Data Into Html
Transforming Xml Data Into Html
 
XML Bible
XML BibleXML Bible
XML Bible
 
XML Transformations With PHP
XML Transformations With PHPXML Transformations With PHP
XML Transformations With PHP
 
Php Mysql Feedrss
Php Mysql FeedrssPhp Mysql Feedrss
Php Mysql Feedrss
 
Rapid html & css coding with emmet
Rapid html & css coding with emmetRapid html & css coding with emmet
Rapid html & css coding with emmet
 
WDIM268 Week 6 (Summer 2010)
WDIM268 Week 6 (Summer 2010)WDIM268 Week 6 (Summer 2010)
WDIM268 Week 6 (Summer 2010)
 
Css, xhtml, javascript
Css, xhtml, javascriptCss, xhtml, javascript
Css, xhtml, javascript
 
PHPTAL introduction
PHPTAL introductionPHPTAL introduction
PHPTAL introduction
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
 
Optaros Surf Code Camp Lab 4
Optaros Surf Code Camp Lab 4Optaros Surf Code Camp Lab 4
Optaros Surf Code Camp Lab 4
 
XML and XSLT
XML and XSLTXML and XSLT
XML and XSLT
 
Xhtml Css Presentation
Xhtml Css PresentationXhtml Css Presentation
Xhtml Css Presentation
 
Creating Yahoo Mobile Widgets
Creating Yahoo Mobile WidgetsCreating Yahoo Mobile Widgets
Creating Yahoo Mobile Widgets
 
Optaros Surf Code Camp Walkthrough 1
Optaros Surf Code Camp Walkthrough 1Optaros Surf Code Camp Walkthrough 1
Optaros Surf Code Camp Walkthrough 1
 
Kick start @ html5
Kick start @ html5Kick start @ html5
Kick start @ html5
 
WEB TECHNOLOGIES XML
WEB TECHNOLOGIES XMLWEB TECHNOLOGIES XML
WEB TECHNOLOGIES XML
 
HTML literals, the JSX of the platform
HTML literals, the JSX of the platformHTML literals, the JSX of the platform
HTML literals, the JSX of the platform
 
Front End Website Optimization
Front End Website OptimizationFront End Website Optimization
Front End Website Optimization
 
Google AMP (Accelerated Mobile Pages)
Google AMP (Accelerated Mobile Pages)Google AMP (Accelerated Mobile Pages)
Google AMP (Accelerated Mobile Pages)
 

Mehr von cdw9

Mehr von cdw9 (7)

Debugging Your Plone Site
Debugging Your Plone SiteDebugging Your Plone Site
Debugging Your Plone Site
 
Crafting an Impactful Home Page That Your Editors Will Love
Crafting an Impactful Home Page That Your Editors Will LoveCrafting an Impactful Home Page That Your Editors Will Love
Crafting an Impactful Home Page That Your Editors Will Love
 
Contributing to Open Source (Lightning Talk version)
Contributing to Open Source (Lightning Talk version)Contributing to Open Source (Lightning Talk version)
Contributing to Open Source (Lightning Talk version)
 
Debugging with PDB
Debugging with PDBDebugging with PDB
Debugging with PDB
 
Introduction to Transmogrifier
Introduction to TransmogrifierIntroduction to Transmogrifier
Introduction to Transmogrifier
 
Contributing to Open Source
Contributing to Open SourceContributing to Open Source
Contributing to Open Source
 
Making CSS and Firebug Your New Friends
Making CSS and Firebug Your New FriendsMaking CSS and Firebug Your New Friends
Making CSS and Firebug Your New Friends
 

Kürzlich hochgeladen

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 

Kürzlich hochgeladen (20)

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 

Intro to TAL

  • 1. PLONE SYMPOSIUM EAST 2011 Intro to TAL Chrissy Wainwright
  • 2. What is TAL? PLONE SYMPOSIUM EAST 2011 * Zope Templating Language * Allow for dynamic content in HTML * Does not render in the site
  • 3. TAL Syntax PLONE SYMPOSIUM EAST 2011 <div tal:content=”context/Title”></div> <tal:title content=”context/Title” /> Use an HTML tag or <tal:whatever...
  • 4. 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
  • 5. TAL Syntax PLONE SYMPOSIUM EAST 2011 <div tal:condition=”python:phone and fax”> Python expressions allow us to put Python code directly in the template. This is not meant for long, complex expressions.
  • 6. TAL Syntax PLONE SYMPOSIUM EAST 2011 <a tal:attributes= ”href string:${item/url}/folder”> With string expressions, we can add static text to dynamic content or combine multiple variables
  • 7. TAL Commands PLONE SYMPOSIUM EAST 2011 * define * condition * repeat * content/replace * attributes * omit-tag
  • 8. tal:define PLONE SYMPOSIUM EAST 2011 * defines variables <div id=”portal-breadcrumbs” tal:define=”breadcrumbs view/breadcrumbs”>
  • 9. tal:condition PLONE SYMPOSIUM EAST 2011 * evaluates an expression * display element if True * omit element if False
  • 10. 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>
  • 11. tal:repeat PLONE SYMPOSIUM EAST 2011 * repeats over a set of elements * available variables: * index / number * even / odd * start / end * length
  • 12. 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>
  • 13. 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>
  • 14. tal:content PLONE SYMPOSIUM EAST 2011 use ‘structure’ for content with HTML code, so the code is not rendered as text <tal:body content=”structure context/getText” />
  • 15. 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>
  • 16. 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>
  • 17. tal:attributes PLONE SYMPOSIUM EAST 2011 allows 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>
  • 18. 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
  • 19. tal:omit-tag PLONE SYMPOSIUM EAST 2011 <a href=”#” tal:define=”url crumb/absolute_url” tal:omit-tag=”not:url” tal:attributes=”href url”>
  • 20. Macros PLONE SYMPOSIUM EAST 2011 The Macro Expansion Template Attribute Language (METAL) allows us to create macros within our page templates, which saves us from repeating code. * define-macro / use-macro * define-slot / fill-slot
  • 21. 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>
  • 22. 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>
  • 23. PLONE SYMPOSIUM EAST 2011 eck out Ch p. com/d emos six feetu