Activate your free membership today | Log-in

Tuesday, January 8th, 2008

XUL Templates

Category: Firefox

Mark Finkle has posted about new datasources for XUL templating which links to a nice tutorial.

I hope to see more XUL/like features finding their way into the Open Web.

Take a look at some of the examples:

Using vbox to use fun box model stuff and create a simple vertical box:

XML:
  1.  
  2. <vbox datasources="rdf:bookmarks" ref="NC:BookmarksRoot" flex="1">
  3.   <template>
  4.     <button uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#Name"/>
  5.   </template>
  6. </vbox>
  7.  

The example below shows how we might set other attributes of a button using a datasource. Of course, this assumes that the datasource supplies the appropriate resources. If a particular one is not found, the value of the attribute will be set to an empty string:

XML:
  1.  
  2. <button class="rdf:http://www.example.com/rdf#class"
  3.         uri="rdf:*"
  4.         label="rdf:http://www.example.com/rdf#name"
  5.         crop="rdf:http://www.example.com/rdf#crop"/>
  6.  

Using rules:

XML:
  1.  
  2. <window id="example-window"
  3.   title="Bookmarks List"
  4.   xmlns:html="http://www.w3.org/1999/xhtml"
  5.   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
  6.   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  7.  
  8.  <vbox datasources="rdf:bookmarks" ref="NC:BookmarksRoot" flex="1">
  9.    <template>
  10.  
  11.     <rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
  12.      <spacer uri="rdf:*" height="16"/>
  13.     </rule>
  14.  
  15.     <rule>
  16.       <button uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#Name"/>
  17.     </rule>
  18.  
  19.   </template>
  20.  </vbox>
  21. </window>
  22.  

Posted by Dion Almaer at 9:01 am

++---
2.8 rating from 12 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.