SlideShare uma empresa Scribd logo
1 de 77
Baixar para ler offline
T3C0N09 Dallas                  Inspiring people to
                                share
Fluid - The Zen of Templating
Fluid - The Zen of Templating
                 16.04.2009



Sebastian Kurfürst <sebastian@typo3.org>
- WARNING -
                                TYPO3 addict




                                Inspiring people to
Fluid - The Zen of Templating   share
Target audience


                TYPO3 v4 Developers



                TYPO3 v5 Developers


                                      Inspiring people to
Fluid - The Zen of Templating         share
TYPO3 v4 and v5


                    v4          v5




                                     Inspiring people to
Fluid - The Zen of Templating        share
Abstract
  Current Template Engines

 How should templating be?
                                     Basic ingredients

                                Fluid in FLOW3 and TYPO3 v4
             Fluid
                                    A practical example

                                Writing a custom ViewHelper
          Next steps

                                           Inspiring people to
Fluid - The Zen of Templating              share
Abstract
  Current Template Engines

 How should templating be?
                                     Basic ingredients

                                Fluid in FLOW3 and TYPO3 v4
             Fluid
                                    A practical example

                                Writing a custom ViewHelper
          Next steps

                                           Inspiring people to
Fluid - The Zen of Templating              share
Current template engines


What should a template engine do?
      renders data

      “lives” in the view




                                    Inspiring people to
Fluid - The Zen of Templating       share
Designers don‘t write PHP, they write HTML
Source: http://en.wikipedia.org/wiki/Template_engine_(web)




                                                                    Inspiring people to
Fluid - The Zen of Templating                                      share
Current template engines
 Classic TYPO3              Smarty    PHPTAL
  Templating




                                          Inspiring people to
Fluid - The Zen of Templating             share
Current Template Engines


Classic TYPO3 Templating
      marker / subpart based

      no control flow

      not extensible

      working with arrays / objects not possible




                                                   Inspiring people to
Fluid - The Zen of Templating                      share
Current Template Engines


Classic TYPO3 Templating

                           ###CONTENTS###

                            <h2>###TITLE###</h2>
                                      Text

                           ###CONTENTS###




                                                   Inspiring people to
Fluid - The Zen of Templating                      share
Current Template Engines


Classic TYPO3 Templating


                           Implementing a loop
                                   Text




                                                 Inspiring people to
Fluid - The Zen of Templating                    share
Current Template Engines


       Classic TYPO3 Templating

###CONTENTS###
                           $subEl = getSubpart(“SUBELEMENT“);
  <ul>
                           $out = ‘‘;    Text
    ###SUBELEMENT###
                           foreach ($recordList as $record) {
      <li>###TITLE###</li>
                               $out .= substituteMarker($subEl, ‘TITLE‘, $record[‘title‘]);
    ###SUBELEMENT###
                           }
  </ul>
                           return substituteSubpart($template, ‘SUBELEMENT‘, $out);
###CONTENTS###

                                                                 Inspiring people to
       Fluid - The Zen of Templating                             share
Current Template Engines


Smarty
    <ul>
    {foreach from=$myArray item=foo}
       <li>{$foo}</li>
    {/foreach}
    </ul>




                                       Inspiring people to
Fluid - The Zen of Templating          share
Current Template Engines


Smarty
      PHP4 based

      custom {...} syntax - no autocompletion

      functions belong to language -> not namespaced

      built-in functions

      custom functions can collide with each other




                                                       Inspiring people to
Fluid - The Zen of Templating                          share
Current Template Engines


PHPTAL

<div class=quot;itemquot; tal:repeat=quot;item itemsArrayquot;>
  <span tal:condition=quot;item/hasDatequot; tal:replace=quot;item/getDatequot;/>
  <a href=quot;${item/getUrl}quot; tal:content=quot;item/getTitlequot;/>
 <p tal:content=quot;value/getContentquot;/>
</div>




                                                    Inspiring people to
Fluid - The Zen of Templating                       share
Current Template Engines


PHPTAL
      well-formed XML, but NOT VALID (no DTD / Schema)

      weird semantics

      PHP in template possible

      No autocompletion

      Difficult to extend




                                                         Inspiring people to
Fluid - The Zen of Templating                            share
Current Template Engines


Drawbacks of existing template engines
      not completely OOP / break OOP paradigms at some places

      difficult to use for non-HTML templates

      no autocompletion in editors

      not easily extensible




                                                                Inspiring people to
Fluid - The Zen of Templating                                   share
Abstract
  Current Template Engines

 How should templating be?
                                     Basic ingredients

                                Fluid in FLOW3 and TYPO3 v4
             Fluid
                                    A practical example

                                Writing a custom ViewHelper
          Next steps

                                           Inspiring people to
Fluid - The Zen of Templating              share
The Zen of
                    Templating



simple   powerful
                           http://www.sxc.hu/photo/821903
The Zen of
                     Templating



intuitive   easily extensible
                                http://www.sxc.hu/photo/821903
»      Simplicity is the ultimate sophistication.


                                                                            «
                                                     Leonardo Da Vinci


                                                      Inspiring people to
Fluid - The Zen of Templating                         share
Goals of Fluid
simple, elegant
                                                    template engine




http://www.flickr.com/photos/josefstuefer/9699426/
Help the template writer
     in many ways
Easy and clean
         extensibility

http://www.sxc.hu/photo/338064
Support for different
  output formats
How should templating be


Goals of Fluid
     Simple, elegant template engine

     support for the template writer in many ways

     simple and clean extensibility

     different output formats possible




                                                    Inspiring people to
Fluid - The Zen of Templating                       share
Abstract
  Current Template Engines

 How should templating be?
                                     Basic ingredients

                                Fluid in FLOW3 and TYPO3 v4
             Fluid
                                    A practical example

                                Writing a custom ViewHelper
          Next steps

                                           Inspiring people to
Fluid - The Zen of Templating              share
http://www.sxc.hu/photo/816749




          Basic ingredients
Basic ingredients


Variables
      $this->view->assign(‘blogTitle’, $blog->getTitle());

      <h1>The name of the blog is: {blogTitle}</h1>




                                                             Inspiring people to
Fluid - The Zen of Templating                                share
Basic ingredients


Object accessors
      $this->view->assign(‘blog’, $blog);

      <h1>The name of the blog is: {blog.title}</h1>
                           Author: {blog.author}

                                                       can be nested
      Getters are called automatically




                                                          Inspiring people to
Fluid - The Zen of Templating                             share
Basic ingredients


     ViewHelpers (Tags)                                           Namespace
                                                                  Declaration
           Output logic is encapsulated in View Helpers (Tags)

           {namespace f=F3FluidViewHelpers}
v5         <f:link action=“someAction“>Administration</f:link>

                                                                 Invocation of
           {namespace f=Tx_Fluid_ViewHelpers}                        a tag
v4
           <f:link action=“someAction“>Administration</f:link>




                                                                         Inspiring people to
     Fluid - The Zen of Templating                                       share
Fluid Core does not contain any output
    logic, and no control structures!
<f:...>

Every tag is a class!
{namespace f=F3FluidViewHelpers}
v5

               <f:link>...</f:link>


     F3FluidViewHelpersLinkViewHelper
{namespace f=Tx_Fluid_ViewHelpers}
v4

               <f:link>...</f:link>


     Tx_Fluid_ViewHelpers_LinkViewHelper
{namespace f=F3FluidViewHelpers}
v5

             <f:form.textbox />


F3FluidViewHelpersFormTextboxViewHelper
Basic ingredients


Arrays
      <f:link action=“show“ arguments=“{id: blog.id, name: ‘Hello’}“>show posting</
      f:link>

      JSON object syntax




                                                                     Inspiring people to
Fluid - The Zen of Templating                                        share
Basic ingredients


Basic ingredients
      Object accessors: {blog.title}

      ViewHelpers: <f:for each=“{blog.posts}“ as=“post“>...</f:for>

      Arrays




                                                                      Inspiring people to
Fluid - The Zen of Templating                                         share
Abstract
  Current Template Engines

 How should templating be?
                                     Basic ingredients

                                Fluid in FLOW3 and TYPO3 v4
             Fluid
                                    A practical example

                                Writing a custom ViewHelper
          Next steps

                                           Inspiring people to
Fluid - The Zen of Templating              share
Fluid in FLOW3 and TYPO3 4.3
    Fluid is included in TYPO3 4.3 and FLOW3

    Difference: Class names, ViewHelpers




                                               Inspiring people to
Fluid - The Zen of Templating                  share
Fluid in FLOW3 and TYPO3 4.3


    Class naming
FLOW3                               TYPO3 4.3


namespace F3FluidViewHelpers;
class ForViewHelper {               class Tx_Fluid_ViewHelpers_ForViewHelper {
 ...                                 ...
}                                   }



                                                          Inspiring people to
    Fluid - The Zen of Templating                         share
Fluid in FLOW3 and TYPO3 4.3


    Class naming
FLOW3                                TYPO3 4.3



{namespace f=F3FluidViewHelpers}   {namespace f=Tx_Fluid_ViewHelpers}




                                                       Inspiring people to
    Fluid - The Zen of Templating                     share
Fluid in FLOW3 and TYPO3 4.3


Class naming



Only the class names are different.


                                Inspiring people to
Fluid - The Zen of Templating   share
Fluid in FLOW3 and TYPO3 4.3


   Class naming



Everything applies to FLOW3 and TYPO3 4.3.


                                   Inspiring people to
   Fluid - The Zen of Templating   share
Fluid in FLOW3 and TYPO3 4.3


Internal structure

                           TemplateView    View Helpers (Tags)
                        TemplateView    View Helpers (Tags)
v5            v4

                                     Fluid Core
     v5v4




                                                          Inspiring people to
Fluid - The Zen of Templating                             share
Abstract
  Current Template Engines

 How should templating be?
                                     Basic ingredients

                                Fluid in FLOW3 and TYPO3 v4
             Fluid
                                    A practical example

                                Writing a custom ViewHelper
          Next steps

                                           Inspiring people to
Fluid - The Zen of Templating              share
A practical example
                                v5




                                         Inspiring people to
Fluid - The Zen of Templating            share
v5
An example
v5
     Layouts
An example
v5
     Loops
Abstract
  Current Template Engines

 How should templating be?
                                     Basic ingredients

                                Fluid in FLOW3 and TYPO3 v4
             Fluid
                                    A practical example

                                Writing a custom ViewHelper
          Next steps

                                           Inspiring people to
Fluid - The Zen of Templating              share
Writing your own ViewHelper
v4
         ViewHelpers encapsulate output logic.




                                                 Inspiring people to
     Fluid - The Zen of Templating               share
Writing your own view helper


     Task: Write a “Gravatar“ ViewHelper
v4
           should take an e-mail address and output the gravatar image, if any.

           Expected output:
           <img src=“http://www.gravatar.com/avatar/md5($email).jpg“ />




                                                                           Inspiring people to
     Fluid - The Zen of Templating                                         share
Writing your own view helper


     Task: Write a “Gravatar“ ViewHelper
v4
           Expected usage:

           {namespace blog=Tx_Blog_ViewHelpers}
           <blog:gravatar email=“sebastian@typo3.org“ />




                                                           Inspiring people to
     Fluid - The Zen of Templating                         share
Writing your own view helper


     1. Create a ViewHelper skeleton
v4


       class Tx_Blog_ViewHelpers_GravatarViewHelper extends Tx_Fluid_Core_AbstractViewHelper {
          public function render() {
             return ‘Hello World‘;
          }
       }



        This will output “Hello World” when the ViewHelper is rendered.


                                                                          Inspiring people to
     Fluid - The Zen of Templating                                        share
Writing your own view helper


     2. Implement the ViewHelper!
v4

                                The PHPDoc must exist
                                  (for validation)
       /**
        * @param string $email The email to render as gravatar
        */
       public function render($email) {
          return ‘http://www.gravatar.com/gravatar/‘ . md5($email);
                                                                      All method parameters will
       }                                                                be ViewHelper arguments
                                                                              automatically




                                                                          Inspiring people to
     Fluid - The Zen of Templating                                        share
Abstract
  Current Template Engines

 How should templating be?
                                     Basic ingredients

                                Fluid in FLOW3 and TYPO3 v4
             Fluid
                                    A practical example

                                Writing a custom ViewHelper
          Next steps

                                           Inspiring people to
Fluid - The Zen of Templating              share
Next steps




                                       Inspiring people to
Fluid - The Zen of Templating          share
Helping the template writer




                                           Inspiring people to
Fluid - The Zen of Templating          share
Autocompletion wizard




                                        Inspiring people to
Fluid - The Zen of Templating           share
Next steps


Autocompletion
      Generate XML Schema of source code comments

      should work with all XML Schema aware editors (tested with Eclipse)




                                                                      Inspiring people to
Fluid - The Zen of Templating                                        share
Next steps


Automatic documentation generation
      PHPDoc comments are enforced

      ViewHelper reference generated automatically from this




                                                               Inspiring people to
Fluid - The Zen of Templating                                  share
Conclusion
Conclusion


Avoiding the drawbacks
      Fluid is completely object oriented

      easy to use for non-HTML templates

      Planned: autocompletion in editors

      Extensibility is a core concept of Fluid - Eat your own dogfood!




                                                                         Inspiring people to
Fluid - The Zen of Templating                                            share
Conclusion


The next-generation template engine
      Fluid will be used in FLOW3 and TYPO3 v4

      People need to learn it only once




                                                 Inspiring people to
Fluid - The Zen of Templating                    share
Work in Progress
          http://www.sxc.hu/photo/956013
We need help and
       feedback!
          http://www.sxc.hu/photo/1132907
??????
                                  ?
                                 ?
                                ?
                              ??
                             ?
                             ?


                                      Inspiring people to
Fluid - The Zen of Templating         share
inspiring people to share.

Mais conteúdo relacionado

Semelhante a Fluid - The Zen of Templating Guide for TYPO3 Developers

Hitchhiker’s Guide to TYPO3 5.0
Hitchhiker’s Guide to TYPO3 5.0Hitchhiker’s Guide to TYPO3 5.0
Hitchhiker’s Guide to TYPO3 5.0Robert Lemke
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPKarsten Dambekalns
 
A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0Karsten Dambekalns
 
Flink Forward SF 2017: Dean Wampler - Streaming Deep Learning Scenarios with...
Flink Forward SF 2017: Dean Wampler -  Streaming Deep Learning Scenarios with...Flink Forward SF 2017: Dean Wampler -  Streaming Deep Learning Scenarios with...
Flink Forward SF 2017: Dean Wampler - Streaming Deep Learning Scenarios with...Flink Forward
 
HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011Alessandro Nadalin
 
Double the Collaboration Value of Confluence - Ben Mackie
Double the Collaboration Value of Confluence - Ben MackieDouble the Collaboration Value of Confluence - Ben Mackie
Double the Collaboration Value of Confluence - Ben MackieAtlassian
 
Digital Library Federation, Fall 07, Connotea Presentation
Digital Library Federation, Fall 07, Connotea PresentationDigital Library Federation, Fall 07, Connotea Presentation
Digital Library Federation, Fall 07, Connotea PresentationIan Mulvany
 
Introduction to Semantic Web for GIS Practitioners
Introduction to Semantic Web for GIS PractitionersIntroduction to Semantic Web for GIS Practitioners
Introduction to Semantic Web for GIS PractitionersEmanuele Della Valle
 
Realizing a Semantic Web Application - ICWE 2010 Tutorial
Realizing a Semantic Web Application - ICWE 2010 TutorialRealizing a Semantic Web Application - ICWE 2010 Tutorial
Realizing a Semantic Web Application - ICWE 2010 TutorialEmanuele Della Valle
 
Workflows with TYPO3 Workspaces 4.5
Workflows with TYPO3 Workspaces 4.5Workflows with TYPO3 Workspaces 4.5
Workflows with TYPO3 Workspaces 4.5Benni Mack
 
Contribute to TYPO3 CMS
Contribute to TYPO3 CMSContribute to TYPO3 CMS
Contribute to TYPO3 CMSOliver Hader
 
Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Feihong Hsu
 

Semelhante a Fluid - The Zen of Templating Guide for TYPO3 Developers (13)

Hitchhiker’s Guide to TYPO3 5.0
Hitchhiker’s Guide to TYPO3 5.0Hitchhiker’s Guide to TYPO3 5.0
Hitchhiker’s Guide to TYPO3 5.0
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHP
 
A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0
 
Flink Forward SF 2017: Dean Wampler - Streaming Deep Learning Scenarios with...
Flink Forward SF 2017: Dean Wampler -  Streaming Deep Learning Scenarios with...Flink Forward SF 2017: Dean Wampler -  Streaming Deep Learning Scenarios with...
Flink Forward SF 2017: Dean Wampler - Streaming Deep Learning Scenarios with...
 
HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011
 
Double the Collaboration Value of Confluence - Ben Mackie
Double the Collaboration Value of Confluence - Ben MackieDouble the Collaboration Value of Confluence - Ben Mackie
Double the Collaboration Value of Confluence - Ben Mackie
 
Digital Library Federation, Fall 07, Connotea Presentation
Digital Library Federation, Fall 07, Connotea PresentationDigital Library Federation, Fall 07, Connotea Presentation
Digital Library Federation, Fall 07, Connotea Presentation
 
Introduction to Semantic Web for GIS Practitioners
Introduction to Semantic Web for GIS PractitionersIntroduction to Semantic Web for GIS Practitioners
Introduction to Semantic Web for GIS Practitioners
 
Why Startups Are Still On AWS
Why Startups Are Still On AWSWhy Startups Are Still On AWS
Why Startups Are Still On AWS
 
Realizing a Semantic Web Application - ICWE 2010 Tutorial
Realizing a Semantic Web Application - ICWE 2010 TutorialRealizing a Semantic Web Application - ICWE 2010 Tutorial
Realizing a Semantic Web Application - ICWE 2010 Tutorial
 
Workflows with TYPO3 Workspaces 4.5
Workflows with TYPO3 Workspaces 4.5Workflows with TYPO3 Workspaces 4.5
Workflows with TYPO3 Workspaces 4.5
 
Contribute to TYPO3 CMS
Contribute to TYPO3 CMSContribute to TYPO3 CMS
Contribute to TYPO3 CMS
 
Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Asynchronous I/O in Python 3
Asynchronous I/O in Python 3
 

Mais de Sebastian Kurfürst

Mais de Sebastian Kurfürst (7)

FLOW3 Goes Semantic
FLOW3 Goes SemanticFLOW3 Goes Semantic
FLOW3 Goes Semantic
 
Advanced Fluid
Advanced FluidAdvanced Fluid
Advanced Fluid
 
Fluid for Designers
Fluid for DesignersFluid for Designers
Fluid for Designers
 
Workshop Extension-Entwicklung mit Extbase und Fluid
Workshop Extension-Entwicklung mit Extbase und FluidWorkshop Extension-Entwicklung mit Extbase und Fluid
Workshop Extension-Entwicklung mit Extbase und Fluid
 
MVC for TYPO3 4.3 with extbase
MVC for TYPO3 4.3 with extbaseMVC for TYPO3 4.3 with extbase
MVC for TYPO3 4.3 with extbase
 
FLOW3 - der aktuelle Stand. TYPO3 Usergroup Dresden
FLOW3 - der aktuelle Stand. TYPO3 Usergroup DresdenFLOW3 - der aktuelle Stand. TYPO3 Usergroup Dresden
FLOW3 - der aktuelle Stand. TYPO3 Usergroup Dresden
 
Continuous Integration at T3CON08
Continuous Integration at T3CON08Continuous Integration at T3CON08
Continuous Integration at T3CON08
 

Último

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Último (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Fluid - The Zen of Templating Guide for TYPO3 Developers

  • 1. T3C0N09 Dallas Inspiring people to share Fluid - The Zen of Templating
  • 2. Fluid - The Zen of Templating 16.04.2009 Sebastian Kurfürst <sebastian@typo3.org>
  • 3. - WARNING - TYPO3 addict Inspiring people to Fluid - The Zen of Templating share
  • 4. Target audience TYPO3 v4 Developers TYPO3 v5 Developers Inspiring people to Fluid - The Zen of Templating share
  • 5. TYPO3 v4 and v5 v4 v5 Inspiring people to Fluid - The Zen of Templating share
  • 6. Abstract Current Template Engines How should templating be? Basic ingredients Fluid in FLOW3 and TYPO3 v4 Fluid A practical example Writing a custom ViewHelper Next steps Inspiring people to Fluid - The Zen of Templating share
  • 7. Abstract Current Template Engines How should templating be? Basic ingredients Fluid in FLOW3 and TYPO3 v4 Fluid A practical example Writing a custom ViewHelper Next steps Inspiring people to Fluid - The Zen of Templating share
  • 8. Current template engines What should a template engine do? renders data “lives” in the view Inspiring people to Fluid - The Zen of Templating share
  • 9. Designers don‘t write PHP, they write HTML
  • 10. Source: http://en.wikipedia.org/wiki/Template_engine_(web) Inspiring people to Fluid - The Zen of Templating share
  • 11. Current template engines Classic TYPO3 Smarty PHPTAL Templating Inspiring people to Fluid - The Zen of Templating share
  • 12. Current Template Engines Classic TYPO3 Templating marker / subpart based no control flow not extensible working with arrays / objects not possible Inspiring people to Fluid - The Zen of Templating share
  • 13. Current Template Engines Classic TYPO3 Templating ###CONTENTS### <h2>###TITLE###</h2> Text ###CONTENTS### Inspiring people to Fluid - The Zen of Templating share
  • 14. Current Template Engines Classic TYPO3 Templating Implementing a loop Text Inspiring people to Fluid - The Zen of Templating share
  • 15. Current Template Engines Classic TYPO3 Templating ###CONTENTS### $subEl = getSubpart(“SUBELEMENT“); <ul> $out = ‘‘; Text ###SUBELEMENT### foreach ($recordList as $record) { <li>###TITLE###</li> $out .= substituteMarker($subEl, ‘TITLE‘, $record[‘title‘]); ###SUBELEMENT### } </ul> return substituteSubpart($template, ‘SUBELEMENT‘, $out); ###CONTENTS### Inspiring people to Fluid - The Zen of Templating share
  • 16.
  • 17. Current Template Engines Smarty <ul> {foreach from=$myArray item=foo} <li>{$foo}</li> {/foreach} </ul> Inspiring people to Fluid - The Zen of Templating share
  • 18. Current Template Engines Smarty PHP4 based custom {...} syntax - no autocompletion functions belong to language -> not namespaced built-in functions custom functions can collide with each other Inspiring people to Fluid - The Zen of Templating share
  • 19. Current Template Engines PHPTAL <div class=quot;itemquot; tal:repeat=quot;item itemsArrayquot;> <span tal:condition=quot;item/hasDatequot; tal:replace=quot;item/getDatequot;/> <a href=quot;${item/getUrl}quot; tal:content=quot;item/getTitlequot;/> <p tal:content=quot;value/getContentquot;/> </div> Inspiring people to Fluid - The Zen of Templating share
  • 20. Current Template Engines PHPTAL well-formed XML, but NOT VALID (no DTD / Schema) weird semantics PHP in template possible No autocompletion Difficult to extend Inspiring people to Fluid - The Zen of Templating share
  • 21. Current Template Engines Drawbacks of existing template engines not completely OOP / break OOP paradigms at some places difficult to use for non-HTML templates no autocompletion in editors not easily extensible Inspiring people to Fluid - The Zen of Templating share
  • 22.
  • 23. Abstract Current Template Engines How should templating be? Basic ingredients Fluid in FLOW3 and TYPO3 v4 Fluid A practical example Writing a custom ViewHelper Next steps Inspiring people to Fluid - The Zen of Templating share
  • 24. The Zen of Templating simple powerful http://www.sxc.hu/photo/821903
  • 25. The Zen of Templating intuitive easily extensible http://www.sxc.hu/photo/821903
  • 26. » Simplicity is the ultimate sophistication. « Leonardo Da Vinci Inspiring people to Fluid - The Zen of Templating share
  • 28. simple, elegant template engine http://www.flickr.com/photos/josefstuefer/9699426/
  • 29. Help the template writer in many ways
  • 30. Easy and clean extensibility http://www.sxc.hu/photo/338064
  • 31. Support for different output formats
  • 32. How should templating be Goals of Fluid Simple, elegant template engine support for the template writer in many ways simple and clean extensibility different output formats possible Inspiring people to Fluid - The Zen of Templating share
  • 33.
  • 34. Abstract Current Template Engines How should templating be? Basic ingredients Fluid in FLOW3 and TYPO3 v4 Fluid A practical example Writing a custom ViewHelper Next steps Inspiring people to Fluid - The Zen of Templating share
  • 35. http://www.sxc.hu/photo/816749 Basic ingredients
  • 36. Basic ingredients Variables $this->view->assign(‘blogTitle’, $blog->getTitle()); <h1>The name of the blog is: {blogTitle}</h1> Inspiring people to Fluid - The Zen of Templating share
  • 37. Basic ingredients Object accessors $this->view->assign(‘blog’, $blog); <h1>The name of the blog is: {blog.title}</h1> Author: {blog.author} can be nested Getters are called automatically Inspiring people to Fluid - The Zen of Templating share
  • 38. Basic ingredients ViewHelpers (Tags) Namespace Declaration Output logic is encapsulated in View Helpers (Tags) {namespace f=F3FluidViewHelpers} v5 <f:link action=“someAction“>Administration</f:link> Invocation of {namespace f=Tx_Fluid_ViewHelpers} a tag v4 <f:link action=“someAction“>Administration</f:link> Inspiring people to Fluid - The Zen of Templating share
  • 39. Fluid Core does not contain any output logic, and no control structures!
  • 41. {namespace f=F3FluidViewHelpers} v5 <f:link>...</f:link> F3FluidViewHelpersLinkViewHelper
  • 42. {namespace f=Tx_Fluid_ViewHelpers} v4 <f:link>...</f:link> Tx_Fluid_ViewHelpers_LinkViewHelper
  • 43. {namespace f=F3FluidViewHelpers} v5 <f:form.textbox /> F3FluidViewHelpersFormTextboxViewHelper
  • 44. Basic ingredients Arrays <f:link action=“show“ arguments=“{id: blog.id, name: ‘Hello’}“>show posting</ f:link> JSON object syntax Inspiring people to Fluid - The Zen of Templating share
  • 45. Basic ingredients Basic ingredients Object accessors: {blog.title} ViewHelpers: <f:for each=“{blog.posts}“ as=“post“>...</f:for> Arrays Inspiring people to Fluid - The Zen of Templating share
  • 46. Abstract Current Template Engines How should templating be? Basic ingredients Fluid in FLOW3 and TYPO3 v4 Fluid A practical example Writing a custom ViewHelper Next steps Inspiring people to Fluid - The Zen of Templating share
  • 47. Fluid in FLOW3 and TYPO3 4.3 Fluid is included in TYPO3 4.3 and FLOW3 Difference: Class names, ViewHelpers Inspiring people to Fluid - The Zen of Templating share
  • 48. Fluid in FLOW3 and TYPO3 4.3 Class naming FLOW3 TYPO3 4.3 namespace F3FluidViewHelpers; class ForViewHelper { class Tx_Fluid_ViewHelpers_ForViewHelper { ... ... } } Inspiring people to Fluid - The Zen of Templating share
  • 49. Fluid in FLOW3 and TYPO3 4.3 Class naming FLOW3 TYPO3 4.3 {namespace f=F3FluidViewHelpers} {namespace f=Tx_Fluid_ViewHelpers} Inspiring people to Fluid - The Zen of Templating share
  • 50. Fluid in FLOW3 and TYPO3 4.3 Class naming Only the class names are different. Inspiring people to Fluid - The Zen of Templating share
  • 51. Fluid in FLOW3 and TYPO3 4.3 Class naming Everything applies to FLOW3 and TYPO3 4.3. Inspiring people to Fluid - The Zen of Templating share
  • 52. Fluid in FLOW3 and TYPO3 4.3 Internal structure TemplateView View Helpers (Tags) TemplateView View Helpers (Tags) v5 v4 Fluid Core v5v4 Inspiring people to Fluid - The Zen of Templating share
  • 53. Abstract Current Template Engines How should templating be? Basic ingredients Fluid in FLOW3 and TYPO3 v4 Fluid A practical example Writing a custom ViewHelper Next steps Inspiring people to Fluid - The Zen of Templating share
  • 54. A practical example v5 Inspiring people to Fluid - The Zen of Templating share
  • 55. v5
  • 56. An example v5 Layouts
  • 57. An example v5 Loops
  • 58. Abstract Current Template Engines How should templating be? Basic ingredients Fluid in FLOW3 and TYPO3 v4 Fluid A practical example Writing a custom ViewHelper Next steps Inspiring people to Fluid - The Zen of Templating share
  • 59. Writing your own ViewHelper v4 ViewHelpers encapsulate output logic. Inspiring people to Fluid - The Zen of Templating share
  • 60. Writing your own view helper Task: Write a “Gravatar“ ViewHelper v4 should take an e-mail address and output the gravatar image, if any. Expected output: <img src=“http://www.gravatar.com/avatar/md5($email).jpg“ /> Inspiring people to Fluid - The Zen of Templating share
  • 61. Writing your own view helper Task: Write a “Gravatar“ ViewHelper v4 Expected usage: {namespace blog=Tx_Blog_ViewHelpers} <blog:gravatar email=“sebastian@typo3.org“ /> Inspiring people to Fluid - The Zen of Templating share
  • 62. Writing your own view helper 1. Create a ViewHelper skeleton v4 class Tx_Blog_ViewHelpers_GravatarViewHelper extends Tx_Fluid_Core_AbstractViewHelper { public function render() { return ‘Hello World‘; } } This will output “Hello World” when the ViewHelper is rendered. Inspiring people to Fluid - The Zen of Templating share
  • 63. Writing your own view helper 2. Implement the ViewHelper! v4 The PHPDoc must exist (for validation) /** * @param string $email The email to render as gravatar */ public function render($email) { return ‘http://www.gravatar.com/gravatar/‘ . md5($email); All method parameters will } be ViewHelper arguments automatically Inspiring people to Fluid - The Zen of Templating share
  • 64. Abstract Current Template Engines How should templating be? Basic ingredients Fluid in FLOW3 and TYPO3 v4 Fluid A practical example Writing a custom ViewHelper Next steps Inspiring people to Fluid - The Zen of Templating share
  • 65. Next steps Inspiring people to Fluid - The Zen of Templating share
  • 66. Helping the template writer Inspiring people to Fluid - The Zen of Templating share
  • 67. Autocompletion wizard Inspiring people to Fluid - The Zen of Templating share
  • 68.
  • 69. Next steps Autocompletion Generate XML Schema of source code comments should work with all XML Schema aware editors (tested with Eclipse) Inspiring people to Fluid - The Zen of Templating share
  • 70. Next steps Automatic documentation generation PHPDoc comments are enforced ViewHelper reference generated automatically from this Inspiring people to Fluid - The Zen of Templating share
  • 72. Conclusion Avoiding the drawbacks Fluid is completely object oriented easy to use for non-HTML templates Planned: autocompletion in editors Extensibility is a core concept of Fluid - Eat your own dogfood! Inspiring people to Fluid - The Zen of Templating share
  • 73. Conclusion The next-generation template engine Fluid will be used in FLOW3 and TYPO3 v4 People need to learn it only once Inspiring people to Fluid - The Zen of Templating share
  • 74. Work in Progress http://www.sxc.hu/photo/956013
  • 75. We need help and feedback! http://www.sxc.hu/photo/1132907
  • 76. ?????? ? ? ? ?? ? ? Inspiring people to Fluid - The Zen of Templating share