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:

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

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:

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

Using rules:

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

Posted by Dion Almaer at 9:01 am
Comment here

2.9 rating from 18 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.