]> git.sesse.net Git - xml-template/commitdiff
Change the syntax for attributes from tag.attribute to tag/attribute; we
authorsgunderson@bigfoot.com <>
Sat, 12 Aug 2006 17:51:18 +0000 (19:51 +0200)
committersgunderson@bigfoot.com <>
Sat, 12 Aug 2006 17:51:18 +0000 (19:51 +0200)
might want classes quite soon, and that would be more logical to have as
tag.class.

doc/intro.txt
perl/XML/Template.pm
perl/attribute.pl
perl/attribute2.pl
php/attribute.php
php/attribute2.php
php/xml-template.php

index f94cef771dbe4e6b5e56e2fcf66a2a414a168d64..e9807e56f1526629215771b4499acef6c2287d2b 100644 (file)
@@ -190,10 +190,10 @@ Code (attribute.pl):
   my $doc = XML::Template::process_file('../xml/clone.xml', {
        'color' => 'red',
        '#things' => [
-               { 'li' => 'Raindrops on roses',    'li.class' => 'odd' },
-               { 'li' => 'Whiskers on kittens',   'li.class' => 'even' },
-               { 'li' => 'Bright copper kettles', 'li.class' => 'odd' },
-               { 'li' => 'Warm, woolen mittens',  'li.class' => 'even' }
+               { 'li' => 'Raindrops on roses',    'li/class' => 'odd' },
+               { 'li' => 'Whiskers on kittens',   'li/class' => 'even' },
+               { 'li' => 'Bright copper kettles', 'li/class' => 'odd' },
+               { 'li' => 'Warm, woolen mittens',  'li/class' => 'even' }
        ]
   });
   print $doc->toString;
index 3d4fad856b1fd4d082dad1a40cc9fec25d071cdc..c148eccf19a8db47e422565a1d4df7ba663ab860 100644 (file)
@@ -83,8 +83,8 @@ sub process {
                                # check all substitutions to see if we found anything
                                # appropriate
                                for my $key (keys %$obj) {
-                                       if (($key =~ /^\Q$tag\E\.(.*)$/) ||
-                                           (defined($id) && $key =~ /^#\Q$id\E\.(.*)$/)) {
+                                       if (($key =~ /^\Q$tag\E\/(.*)$/) ||
+                                           (defined($id) && $key =~ /^#\Q$id\E\/(.*)$/)) {
                                                $child->setAttribute($1, $obj->{$key});
                                        }
 
index 9e4947d459777a8602820e0ed5ec8c2e64044f59..7447652b519b41eb422c7aa98f6e0e3bb5383d99 100644 (file)
@@ -4,10 +4,10 @@ use XML::Template;
 my $doc = XML::Template::process_file('../xml/clone.xml', {
        'color' => 'red',
        '#things' => [
-               { 'li' => 'Raindrops on roses',    'li.class' => 'odd' },
-               { 'li' => 'Whiskers on kittens',   'li.class' => 'even' },
-               { 'li' => 'Bright copper kettles', 'li.class' => 'odd' },
-               { 'li' => 'Warm, woolen mittens',  'li.class' => 'even' }
+               { 'li' => 'Raindrops on roses',    'li/class' => 'odd' },
+               { 'li' => 'Whiskers on kittens',   'li/class' => 'even' },
+               { 'li' => 'Bright copper kettles', 'li/class' => 'odd' },
+               { 'li' => 'Warm, woolen mittens',  'li/class' => 'even' }
        ]
 });
 print $doc->toString;
index 2557d3315f7ffa75c201055a477504d0c89641df..832398e057b9fd308c532590a0f46c90c1560758 100644 (file)
@@ -3,7 +3,7 @@ use XML::Template;
 
 my $doc = XML::Template::process_file('../xml/clone.xml', {
        'color' => 'blue',
-       '#things' => XML::Template::alternate('li.class', [
+       '#things' => XML::Template::alternate('li/class', [
                { 'li' => 'Raindrops on roses' },
                { 'li' => 'Whiskers on kittens' },
                { 'li' => 'Bright copper kettles' },
index b4899b8e6d0461ce75bbd1570eb93a140125ee0d..626812ec9227cb5a7097db944e965940bcf6b7b3 100644 (file)
@@ -4,10 +4,10 @@ require('xml-template.php');
 $doc = XML_Template_process_file('../xml/clone.xml', array(
        'color' => 'red',
        '#things' => array(
-               array( 'li' => 'Raindrops on roses',    'li.class' => 'odd' ),
-               array( 'li' => 'Whiskers on kittens',   'li.class' => 'even' ),
-               array( 'li' => 'Bright copper kettles', 'li.class' => 'odd' ),
-               array( 'li' => 'Warm, woolen mittens',  'li.class' => 'even' )
+               array( 'li' => 'Raindrops on roses',    'li/class' => 'odd' ),
+               array( 'li' => 'Whiskers on kittens',   'li/class' => 'even' ),
+               array( 'li' => 'Bright copper kettles', 'li/class' => 'odd' ),
+               array( 'li' => 'Warm, woolen mittens',  'li/class' => 'even' )
        )
 ));
 print $doc->dump_mem();
index e1450458da7dd69fd920e469ce6f61da187e6bf3..186828f312af85194cf419379df64053f65fb6b9 100644 (file)
@@ -3,7 +3,7 @@ require('xml-template.php');
 
 $doc = XML_Template_process_file('../xml/clone.xml', array(
        'color' => 'blue',
-       '#things' => XML_Template_alternate('li.class', array(
+       '#things' => XML_Template_alternate('li/class', array(
                array( 'li' => 'Raindrops on roses' ),
                array( 'li' => 'Whiskers on kittens' ),
                array( 'li' => 'Bright copper kettles' ),
index dc84bf6e5f8ba023977b997397d3036a9129968f..b5f70965ac18afb9264d63faa4dc4e923cee5232 100644 (file)
@@ -48,8 +48,8 @@ function XML_Template_process($node, $obj, $clean = 1)
                                # appropriate
                                foreach (array_keys($obj) as $key) {
                                        # FIXME: we would want something like \Q and \E here...
-                                       if (preg_match('/^' . $tag . '\.(.*)$/', $key, $matches) ||
-                                           ($id != null && preg_match('/^#' . $id . '\.(.*)$/', $key, $matches))) {
+                                       if (preg_match('/^' . $tag . '\/(.*)$/', $key, $matches) ||
+                                           ($id != null && preg_match('/^#' . $id . '\/(.*)$/', $key, $matches))) {
                                                $child->set_attribute($matches[1], $obj[$key]);
                                        }