You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by he...@apache.org on 2003/04/21 20:41:32 UTC

cvs commit: jakarta-turbine-2/proposals/henning/velocitymacros README TurbineMacros.vm

henning     2003/04/21 11:41:32

  Added:       proposals/henning/velocitymacros README TurbineMacros.vm
  Log:
  First cut at actually implementing the macros that Quinton described in
  HtmlPageAttributes. Please try out and report bugs.
  
  Revision  Changes    Path
  1.1                  jakarta-turbine-2/proposals/henning/velocitymacros/README
  
  Index: README
  ===================================================================
  Velocity Macros for VelocityOnlyLayout
  ======================================
  
  These are two macros which can be used in conjunction with
  VelocityOnlyLayout and HtmlPageAttributes to provide the same
  Functionality as VelocityECSLayout with TemplatePageAttributes.
  
  These macros should be used in the Layout template like this:
  
  --- cut --- Layout Template --- cut ---
  
  ... here you should put things like setting the page name, adding
  style sheets and so on.
  
  <html>
  #TurbineHtmlHead()
  #TurbineHtmlBodyStart()
  .... your body information
  </body>
  </html>
  --- cut --- Layout Template --- cut ---
  
  As the layout template is rendered _after_ the screen template, you
  can of course, add information to the $page tool in your screen
  template. This will be added correctly to the <head>...</head> and
  <body> tags.
  
  
  Adding these Macros to the Turbine Code base
  ============================================
  
  I propose to add these Macros for loading by the classpath loader
  directly from the turbine.jar. To achieve this, the following is added
  to the java:compile postGoal in maven.xml:
  
  <copy
    file="${maven.src.dir}/macros/TurbineMacros.vm"
    todir="${maven.build.dest}/macros"
  />
  
  (assuming the Macro file is put into src/macros/TurbineMacros.vm in the
  Turbine code base)
  
  and then adding a load instruction to the TurbineResources.properties:
  
  services.VelocityService.velocimacro.library = macros/TurbineMacros.vm
  
  Of course, the classpath loader must be configured (it is by default):
  
  services.VelocityService.resource.loader = classpath
  services.VelocityService.classpath.resource.loader.description = Velocity Classpath Resource Loader
  services.VelocityService.classpath.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
  
  
  
  
  
  
  1.1                  jakarta-turbine-2/proposals/henning/velocitymacros/TurbineMacros.vm
  
  Index: TurbineMacros.vm
  ===================================================================
  ## @version $Id: TurbineMacros.vm,v 1.1 2003/04/21 18:41:31 henning Exp $
  ## @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  
  ##
  ## Build the <head> ... </head> tag of a web page with VelocityOnly Layout
  ## 
  #macro (TurbineHtmlHead)
  <head>
    #if ($!page.Title)
      <title>$page.Title</title>
    #end
    #if ($page.MetaTags.size() > 0)
      #foreach($metaTag in $page.MetaTags.keySet())
        <meta name="$metaTag" content="$page.MetaTags.get($metaTag)">
      #end
    #end
    #if ($page.HttpEquivs.size() > 0)
      #foreach($httpEquiv in $page.HttpEquivs.keySet())
        <meta http-equiv="$httpEquiv" content="$page.HttpEquivs.get($httpEquiv)">
      #end
    #end
    #if ($page.StyleSheets.size() > 0)
      #foreach( $styleSheet in $page.StyleSheets )
        <link rel="stylesheet" href="$styleSheet.Url"
          #if($!styleSheet.Type)  type="$styleSheet.Type"   #end
          #if($!styleSheet.Media) media="$styleSheet.Media" #end
          #if($!styleSheet.Title) title="$styleSheet.Title" #end
        >
      #end
    #end
    #if ($page.Scripts.size() > 0)
      #foreach( $script in $page.Scripts )
        <script type="text/javascript" src="$script" language="JavaScript"></script>
      #end
    #end
  </head>
  #end
  
  ##
  ## Build the <body> start tag of a web page with VelocityOnly Layout
  ## 
  #macro (TurbineHtmlBodyStart)
  #if ($page.BodyAttributes.size() > 0)
    <body
      #foreach( $attributeName in $page.BodyAttributes.keySet() )
        $attributeName = "$page.BodyAttributes.get($attributeName)"
      #end
    >
  #else
    <body>
  #end
  #end
  
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org