SlideShare a Scribd company logo
Zope Page Templates
  file:///home/pptfactory/temp/20090701114008/stencil.jpg




                                                                An introduction to Zope Page Templates
                                                                and their use outside of Zope

                                                                Matt Hamilton
                                                                matth@netsight.co.uk




30th June 2009                                              Europython 2009, Birmingham, UK          1
Who Am I
 Technical Director of Netsight
      Web development firm in Bristol, UK




 10 years experience with Zope/Plone
 More of an integrator than core developer
      I get involved in all those sticky projects of merging
         Plone in with other systems in an enterprise

30th June 2009         Europython 2009, Birmingham, UK         2
The Irony of this talk...

   Most of it was taken from a talk
             on PHPTAL!

                                                                          Thanks to Kornel Lesiński who did a
                 file:///home/pptfactory/temp/20090701114008/kornel.jpg




                                                                          talk on it at the Web Standards
                                                                          conference 2008 in London




30th June 2009                                                              Europython 2009, Birmingham, UK     3
What is ZPT/TAL


                 TAL – Template Attribute Language
                   ZPT – Zope Page Templates



                 ZPT = an implementation of TAL



30th June 2009            Europython 2009, Birmingham, UK   4
Zope?! I don't DO Zope!
                 file:///home/pptfactory/temp/20090701114008/2512086374_5da1610fc9.jpg




30th June 2009                                                                           Europython 2009, Birmingham, UK   5
TAL is a standard (sort of)


 Official specification
 http://wiki.zope.org/ZPT/TAL


 Multiple implementations
 http://en.wikipedia.org/wiki/Template_Attribute_Language




30th June 2009       Europython 2009, Birmingham, UK        6
The Idea of Templating

                                              XML/TAL
                 Data
                                              Template



                              ZPT




                           XHTML


30th June 2009          Europython 2009, Birmingham, UK   7
The Idea of Templating

                                 XML/TAL
          Data
                                 Template



                  ZPT



                                   or                or         not   Plain
                 XHTML                    XML             RSS
                                                                      text


30th June 2009          Europython 2009, Birmingham, UK                   8
Why use templates?

      Separate Presentation and Logic
      Keeping code clean
      Multiple presentations of same data (RSS,
       JSON, REST, XML)




30th June 2009     Europython 2009, Birmingham, UK   9
But, why TAL?


      <ul>
        % for name in row:
            <li>${name}</li>
        % endfor
      </ul>



30th June 2009   Europython 2009, Birmingham, UK   10
But, why TAL?
     <ul>
       % for name in row:
           <li>${name}</li>
       % endfor
    </ul>



      <ul>
        <li tal:repeat=”name row”
            tal:content=”name” />
      </ul>

30th June 2009     Europython 2009, Birmingham, UK   11
But, why TAL?

      <ul>
        <li tal:repeat=”name row”
            tal:content=”name”>
        Dummy data
        </li>
      </ul>


30th June 2009   Europython 2009, Birmingham, UK   12
But, why TAL?

      <ul>
        <li tal:repeat=”name row”
            tal:content=”name”>
        Dummy data
        </li>
      </ul>


30th June 2009   Europython 2009, Birmingham, UK   13
Makes well-formed XHTML
easy
      <ul>
        <li>
        % if foo = 'bar':
             ${name}
        </li>                                      Nesting
        % endif                                    Error!
      </ul>


30th June 2009   Europython 2009, Birmingham, UK             14
Makes well-formed XHTML
easy

  <ul>
    <li
tal:condition=”python:foo='bar'”
tal:content=”name” />
  </ul>



30th June 2009   Europython 2009, Birmingham, UK   15
Makes well-formed XHTML
easy


           Ensures that you close all elements
            and quote attributes
           Escapes all ampersands by default &
            -> &amp;



30th June 2009       Europython 2009, Birmingham, UK   16
So, how do I use it?


Create virtualenv
     % virtualenv zptdemo

Install zope.pagetemplate in virtualenv
     % cd zptdemo
     % bin/easy_install zope.pagetemplate



30th June 2009     Europython 2009, Birmingham, UK   17
So, how do I use it?
In mycode.py:
from zope.pagetemplate.pagetemplatefile 
    import PageTemplateFile

my_pt = PageTemplateFile('mytemplate.pt')
context = {'row': ['apple',
                   'banana',
                   'carrot'],
           'foo':'bar'}

print my_pt.pt_render(namespace=context)


30th June 2009   Europython 2009, Birmingham, UK   18
So, how do I use it?
In mytemplate.py:
<html>
<body>
<h1>Hello World</h1>

<div tal:condition=”python:foo == 'bar'”>
<ul>
<li tal:repeat="item rows" tal:content="item" />
</ul>
</div>

</body>
</html>
30th June 2009   Europython 2009, Birmingham, UK   19
So, how do I use it?
End result:
<html>
<body>
<h1>Hello World</h1>

<ul>
<li>apple</li>
<li>banana</li>
<li>carrot</li>
</ul>
</div>

</body>
</html>
30th June 2009    Europython 2009, Birmingham, UK   20
Some TAL niceties



<a href=”href” tal:omit-tag=”not:href”>
   Optionally linked text
</a>

                 Omit the tag if there is href variable
                           evaluates false

30th June 2009             Europython 2009, Birmingham, UK   21
Some TAL niceties


<title tal:content=”page/title |
               site/title | default”>
  My Website
</title>

                 If there is no page title or site title,
                       then use the default text

30th June 2009             Europython 2009, Birmingham, UK   22
Some TAL niceties


<option tal:repeat=”c countries”
        tal:content=”c”
        tal:attributes=”selected
                   python:c==’UK’” />

                 Create an option for each country,
                  and if the UK then set selected

30th June 2009           Europython 2009, Birmingham, UK   23
Some advanced features
                 file:///home/pptfactory/temp/20090701114008/ninja.jpg




                                                 ( but not too many )

30th June 2009                                                           Europython 2009, Birmingham, UK   24
METAL macros
A master template:

<html metal:define-macro=”main”>
  <head><title>My Site</title></head>
  <body>
    <div metal:define-slot=”body”>
      Dummy body
    </div>
  </body>
</html>

30th June 2009   Europython 2009, Birmingham, UK   25
METAL macros
A sub-template for a page:

<html metal:use-macro=
              ”template/macros/main”>
  <head><title>My Site</title></head>
  <body>
    <div metal:fill-slot=”body”>
      This is my real body text
    </div>
  </body>
</html>
30th June 2009   Europython 2009, Birmingham, UK   26
METAL macros



Internationalisation:

<h1 i18n:translate=””>Some text</h1>




30th June 2009    Europython 2009, Birmingham, UK   27
Questions?
                    matth@netsight.co.uk




30th June 2009   Europython 2009, Birmingham, UK   28
We are looking for Developers!

 Come chat to me
 or
 drop an email to

  careers@netsight.co.uk




30th June 2009   Europython 2009, Birmingham, UK   29

More Related Content

Similar to An introduction to Zope Page Templates and their use outside of Zope (+Audio)

Bugtracking on the Web 2.5
Bugtracking on the Web 2.5Bugtracking on the Web 2.5
Bugtracking on the Web 2.5
olberger
 
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume LaforgeGaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
Guillaume Laforge
 
Bpmn 2.0 Eclipse OMG/Symposium
Bpmn 2.0 Eclipse OMG/SymposiumBpmn 2.0 Eclipse OMG/Symposium
Bpmn 2.0 Eclipse OMG/Symposium
Antoine Toulme
 
CS5229 09/10 Lecture 6: Simulation
CS5229 09/10 Lecture 6: SimulationCS5229 09/10 Lecture 6: Simulation
CS5229 09/10 Lecture 6: Simulation
Wei Tsang Ooi
 
Methods to test an e-learning Web application.
Methods to test an e-learning Web application.Methods to test an e-learning Web application.
Methods to test an e-learning Web application.
telss09
 

Similar to An introduction to Zope Page Templates and their use outside of Zope (+Audio) (20)

Acceleo MTL Code Generation
Acceleo MTL Code GenerationAcceleo MTL Code Generation
Acceleo MTL Code Generation
 
Html and visual fox pro
Html and visual fox proHtml and visual fox pro
Html and visual fox pro
 
Beyond The Web: Drupal Meets The Desktop (And Mobile)
Beyond The Web: Drupal Meets The Desktop (And Mobile)Beyond The Web: Drupal Meets The Desktop (And Mobile)
Beyond The Web: Drupal Meets The Desktop (And Mobile)
 
GemStone Update
GemStone UpdateGemStone Update
GemStone Update
 
Bugtracking on the Web 2.5
Bugtracking on the Web 2.5Bugtracking on the Web 2.5
Bugtracking on the Web 2.5
 
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume LaforgeGaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
 
Usdin XML for Standards
Usdin XML for StandardsUsdin XML for Standards
Usdin XML for Standards
 
Bpmn 2.0 Eclipse OMG/Symposium
Bpmn 2.0 Eclipse OMG/SymposiumBpmn 2.0 Eclipse OMG/Symposium
Bpmn 2.0 Eclipse OMG/Symposium
 
Migrating Belgium's Largest Telecommunication Company to Magnolia
Migrating Belgium's Largest Telecommunication Company to Magnolia Migrating Belgium's Largest Telecommunication Company to Magnolia
Migrating Belgium's Largest Telecommunication Company to Magnolia
 
The Ins And Outs Of Capture
The Ins And Outs Of CaptureThe Ins And Outs Of Capture
The Ins And Outs Of Capture
 
Using Entity Framework's New POCO Features: Part 1, by Julie Lerman
Using Entity Framework's New POCO Features: Part 1, by Julie LermanUsing Entity Framework's New POCO Features: Part 1, by Julie Lerman
Using Entity Framework's New POCO Features: Part 1, by Julie Lerman
 
CS5229 09/10 Lecture 6: Simulation
CS5229 09/10 Lecture 6: SimulationCS5229 09/10 Lecture 6: Simulation
CS5229 09/10 Lecture 6: Simulation
 
Module01
Module01Module01
Module01
 
Symfony - modern technology in practice, Webexpo Prague
Symfony - modern technology in practice, Webexpo PragueSymfony - modern technology in practice, Webexpo Prague
Symfony - modern technology in practice, Webexpo Prague
 
"How Mozilla Uses Selenium"
"How Mozilla Uses Selenium""How Mozilla Uses Selenium"
"How Mozilla Uses Selenium"
 
Une décision intelligente dans un environnement hétérogène
Une décision intelligente dans un environnement hétérogèneUne décision intelligente dans un environnement hétérogène
Une décision intelligente dans un environnement hétérogène
 
Methods to test an e-learning Web application.
Methods to test an e-learning Web application.Methods to test an e-learning Web application.
Methods to test an e-learning Web application.
 
Importing/Exporting a project using DIgSILENT PowerFactory
Importing/Exporting a project using DIgSILENT PowerFactoryImporting/Exporting a project using DIgSILENT PowerFactory
Importing/Exporting a project using DIgSILENT PowerFactory
 
Mwml
MwmlMwml
Mwml
 
Python Orientation
Python OrientationPython Orientation
Python Orientation
 

More from Matt Hamilton

More from Matt Hamilton (16)

Ceci n’est pas un canard - Machine Learning and Generative Adversarial Networks
Ceci n’est pas un canard - Machine Learning and Generative Adversarial NetworksCeci n’est pas un canard - Machine Learning and Generative Adversarial Networks
Ceci n’est pas un canard - Machine Learning and Generative Adversarial Networks
 
Ceci N'est Pas Un Canard – and Other Machine Learning Stories
Ceci N'est Pas Un Canard – and Other Machine Learning StoriesCeci N'est Pas Un Canard – and Other Machine Learning Stories
Ceci N'est Pas Un Canard – and Other Machine Learning Stories
 
Intro to Machine Learning and AI
Intro to Machine Learning and AIIntro to Machine Learning and AI
Intro to Machine Learning and AI
 
Open Source, The Natural Fit for Content Management in the Enterprise
Open Source, The Natural Fit for Content Management in the EnterpriseOpen Source, The Natural Fit for Content Management in the Enterprise
Open Source, The Natural Fit for Content Management in the Enterprise
 
Supercharge Your Career with Open Source
Supercharge Your Career with Open SourceSupercharge Your Career with Open Source
Supercharge Your Career with Open Source
 
How to get started with the Pluggable Authentication System
How to get started with the Pluggable Authentication SystemHow to get started with the Pluggable Authentication System
How to get started with the Pluggable Authentication System
 
Plone and Single-Sign On - Active Directory and the Holy Grail
Plone and Single-Sign On - Active Directory and the Holy GrailPlone and Single-Sign On - Active Directory and the Holy Grail
Plone and Single-Sign On - Active Directory and the Holy Grail
 
Mistakes Made and Lessons Learnt Scaling Plone post-Launch
Mistakes Made and Lessons Learnt Scaling Plone post-LaunchMistakes Made and Lessons Learnt Scaling Plone post-Launch
Mistakes Made and Lessons Learnt Scaling Plone post-Launch
 
Plone Symposium East 2011 Keynote: Plone, A Solution not a Product
Plone Symposium East 2011 Keynote: Plone, A Solution not a ProductPlone Symposium East 2011 Keynote: Plone, A Solution not a Product
Plone Symposium East 2011 Keynote: Plone, A Solution not a Product
 
Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)
Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)
Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)
 
The Flexibility of Open Source - Plone in the Public Sector
The Flexibility of Open Source - Plone in the Public SectorThe Flexibility of Open Source - Plone in the Public Sector
The Flexibility of Open Source - Plone in the Public Sector
 
Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)
Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)
Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)
 
Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009
 
Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...
Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...
Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...
 
NextGen Roadshow Bmex Case Study
NextGen Roadshow Bmex Case StudyNextGen Roadshow Bmex Case Study
NextGen Roadshow Bmex Case Study
 
Open Source and Content Management (+audio)
Open Source and Content Management (+audio)Open Source and Content Management (+audio)
Open Source and Content Management (+audio)
 

Recently uploaded

Recently uploaded (20)

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
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
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
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
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
 
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
 
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
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
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
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Buy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptxBuy Epson EcoTank L3210 Colour Printer Online.pptx
Buy Epson EcoTank L3210 Colour Printer Online.pptx
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
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)
 

An introduction to Zope Page Templates and their use outside of Zope (+Audio)

  • 1. Zope Page Templates file:///home/pptfactory/temp/20090701114008/stencil.jpg An introduction to Zope Page Templates and their use outside of Zope Matt Hamilton matth@netsight.co.uk 30th June 2009 Europython 2009, Birmingham, UK 1
  • 2. Who Am I Technical Director of Netsight Web development firm in Bristol, UK 10 years experience with Zope/Plone More of an integrator than core developer I get involved in all those sticky projects of merging Plone in with other systems in an enterprise 30th June 2009 Europython 2009, Birmingham, UK 2
  • 3. The Irony of this talk... Most of it was taken from a talk on PHPTAL! Thanks to Kornel Lesiński who did a file:///home/pptfactory/temp/20090701114008/kornel.jpg talk on it at the Web Standards conference 2008 in London 30th June 2009 Europython 2009, Birmingham, UK 3
  • 4. What is ZPT/TAL TAL – Template Attribute Language ZPT – Zope Page Templates ZPT = an implementation of TAL 30th June 2009 Europython 2009, Birmingham, UK 4
  • 5. Zope?! I don't DO Zope! file:///home/pptfactory/temp/20090701114008/2512086374_5da1610fc9.jpg 30th June 2009 Europython 2009, Birmingham, UK 5
  • 6. TAL is a standard (sort of) Official specification http://wiki.zope.org/ZPT/TAL Multiple implementations http://en.wikipedia.org/wiki/Template_Attribute_Language 30th June 2009 Europython 2009, Birmingham, UK 6
  • 7. The Idea of Templating XML/TAL Data Template ZPT XHTML 30th June 2009 Europython 2009, Birmingham, UK 7
  • 8. The Idea of Templating XML/TAL Data Template ZPT or or not Plain XHTML XML RSS text 30th June 2009 Europython 2009, Birmingham, UK 8
  • 9. Why use templates? Separate Presentation and Logic Keeping code clean Multiple presentations of same data (RSS, JSON, REST, XML) 30th June 2009 Europython 2009, Birmingham, UK 9
  • 10. But, why TAL? <ul> % for name in row: <li>${name}</li> % endfor </ul> 30th June 2009 Europython 2009, Birmingham, UK 10
  • 11. But, why TAL? <ul> % for name in row: <li>${name}</li> % endfor </ul> <ul> <li tal:repeat=”name row” tal:content=”name” /> </ul> 30th June 2009 Europython 2009, Birmingham, UK 11
  • 12. But, why TAL? <ul> <li tal:repeat=”name row” tal:content=”name”> Dummy data </li> </ul> 30th June 2009 Europython 2009, Birmingham, UK 12
  • 13. But, why TAL? <ul> <li tal:repeat=”name row” tal:content=”name”> Dummy data </li> </ul> 30th June 2009 Europython 2009, Birmingham, UK 13
  • 14. Makes well-formed XHTML easy <ul> <li> % if foo = 'bar': ${name} </li> Nesting % endif Error! </ul> 30th June 2009 Europython 2009, Birmingham, UK 14
  • 15. Makes well-formed XHTML easy <ul> <li tal:condition=”python:foo='bar'” tal:content=”name” /> </ul> 30th June 2009 Europython 2009, Birmingham, UK 15
  • 16. Makes well-formed XHTML easy Ensures that you close all elements and quote attributes Escapes all ampersands by default & -> &amp; 30th June 2009 Europython 2009, Birmingham, UK 16
  • 17. So, how do I use it? Create virtualenv % virtualenv zptdemo Install zope.pagetemplate in virtualenv % cd zptdemo % bin/easy_install zope.pagetemplate 30th June 2009 Europython 2009, Birmingham, UK 17
  • 18. So, how do I use it? In mycode.py: from zope.pagetemplate.pagetemplatefile import PageTemplateFile my_pt = PageTemplateFile('mytemplate.pt') context = {'row': ['apple', 'banana', 'carrot'], 'foo':'bar'} print my_pt.pt_render(namespace=context) 30th June 2009 Europython 2009, Birmingham, UK 18
  • 19. So, how do I use it? In mytemplate.py: <html> <body> <h1>Hello World</h1> <div tal:condition=”python:foo == 'bar'”> <ul> <li tal:repeat="item rows" tal:content="item" /> </ul> </div> </body> </html> 30th June 2009 Europython 2009, Birmingham, UK 19
  • 20. So, how do I use it? End result: <html> <body> <h1>Hello World</h1> <ul> <li>apple</li> <li>banana</li> <li>carrot</li> </ul> </div> </body> </html> 30th June 2009 Europython 2009, Birmingham, UK 20
  • 21. Some TAL niceties <a href=”href” tal:omit-tag=”not:href”> Optionally linked text </a> Omit the tag if there is href variable evaluates false 30th June 2009 Europython 2009, Birmingham, UK 21
  • 22. Some TAL niceties <title tal:content=”page/title | site/title | default”> My Website </title> If there is no page title or site title, then use the default text 30th June 2009 Europython 2009, Birmingham, UK 22
  • 23. Some TAL niceties <option tal:repeat=”c countries” tal:content=”c” tal:attributes=”selected python:c==’UK’” /> Create an option for each country, and if the UK then set selected 30th June 2009 Europython 2009, Birmingham, UK 23
  • 24. Some advanced features file:///home/pptfactory/temp/20090701114008/ninja.jpg ( but not too many ) 30th June 2009 Europython 2009, Birmingham, UK 24
  • 25. METAL macros A master template: <html metal:define-macro=”main”> <head><title>My Site</title></head> <body> <div metal:define-slot=”body”> Dummy body </div> </body> </html> 30th June 2009 Europython 2009, Birmingham, UK 25
  • 26. METAL macros A sub-template for a page: <html metal:use-macro= ”template/macros/main”> <head><title>My Site</title></head> <body> <div metal:fill-slot=”body”> This is my real body text </div> </body> </html> 30th June 2009 Europython 2009, Birmingham, UK 26
  • 27. METAL macros Internationalisation: <h1 i18n:translate=””>Some text</h1> 30th June 2009 Europython 2009, Birmingham, UK 27
  • 28. Questions? matth@netsight.co.uk 30th June 2009 Europython 2009, Birmingham, UK 28
  • 29. We are looking for Developers! Come chat to me or drop an email to careers@netsight.co.uk 30th June 2009 Europython 2009, Birmingham, UK 29