Skip to content

Commit

Permalink
POD fix. (I'm writing slide now
Browse files Browse the repository at this point in the history
  • Loading branch information
tomill committed Mar 4, 2010
1 parent c18bb47 commit 1b733ae
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/Template/Semantic.pm
Expand Up @@ -122,7 +122,9 @@ and uses XPath or CSS selectors to assign values.
Constructs a new C<Template::Semantic> object.
my $ts = Template::Semantic->new;
my $ts = Template::Semantic->new(
...
);
my $res = $ts->process(...);
If you do not want to change the options from the defaults, you may skip
Expand Down Expand Up @@ -201,7 +203,9 @@ See the L</Filter> section.
=head1 SELECTOR
Use XPath expression or CSS selector as a selector.
Use XPath expression or CSS selector as a selector. If the expression
doesn't look like XPath, it is considered CSS selector and converted
into XPath internally.
print Template::Semantic->process($template, {
Expand All @@ -217,8 +221,8 @@ Use XPath expression or CSS selector as a selector.
# CSS selector sample that indicate <tag>
'title' => ...,
'.foo span.bar' => ...,
'#foo' => ...,
'.foo span.bar' => ...,
# CSS selector sample that indicate @attr
'img#foo@src' => ...,
Expand All @@ -230,16 +234,15 @@ Use XPath expression or CSS selector as a selector.
Template::Semantic allows some selector syntax that is different
from usual XPath for your convenience.
1. You can specify tag without using L<XML::LibXML::XPathContext>
even if your template has default namespace (C<< <html xmlns="..." >>).
2. You can use 'id()' function to find element with C<id=""> attribute
instead of C<xml:id="">.
1. You can use xpath C<'//div'> without using L<XML::LibXML::XPathContext>
even if your template has default namespace (C<< <html xmlns="..."> >>).
3. If the expression looks like CSS selector, it is converted to XPath
internally.
2. You can use C<'id("foo")'> function to find element with C<id="foo">
instead of C<xml:id="foo"> without DTD. Note: use C<'//*[@xml:id="foo"]'>
if your template uses C<xml:id="foo">.
4. You can specify the attribute by using '@attr' syntax with CSS selector.
3. You can C<'@attr'> syntax with CSS selector that specifies the attribute.
This is original syntax of this module.
=head1 VALUE TYPE
Expand Down
39 changes: 39 additions & 0 deletions t/06_libxml-hack.t
Expand Up @@ -14,6 +14,30 @@ __DATA__
<span id="foo">xxx</span>
</div>
=== id() cannot catch xml:id
--- vars
'id("foo")' => 'xxx'
--- template
<div>
<span xml:id="foo">foo</span>
</div>
--- expected
<div>
<span xml:id="foo">foo</span>
</div>
=== use @xml:id="" instead of id()
--- vars
'//*[@xml:id="foo"]' => 'xxx'
--- template
<div>
<span xml:id="foo">foo</span>
</div>
--- expected
<div>
<span xml:id="foo">xxx</span>
</div>
=== xhtml default xmlns hack
--- vars
'//span' => 'xxx'
Expand All @@ -26,6 +50,21 @@ __DATA__
<span>xxx</span>
</html>
=== xhtml with xmlns
--- vars
'//span' => 'xxx',
'//foo:span' => 'zzz',
--- template
<html xmlns:foo="http://example/foo">
<span>foo</span>
<foo:span>foo</foo:span>
</html>
--- expected
<html xmlns:foo="http://example/foo">
<span>xxx</span>
<foo:span>zzz</foo:span>
</html>
=== no dtd, no xml declaration
--- vars
'//foo' => 'xxx'
Expand Down

0 comments on commit 1b733ae

Please sign in to comment.