[jifty-devel] Idea for Template::Declare::XML
Andrew Sterling Hanenkamp
sterling at hanenkamp.com
Thu Aug 9 09:22:19 EDT 2007
agentz,
The TagSet stuff in TD is cool, btw.
On 8/9/07, Agent Zhang <agentzh at gmail.com> wrote:
>
> On 7/14/07, Andrew Sterling Hanenkamp <sterling at hanenkamp.com> wrote:
> > Here's a sample of what I was thinking:
> >
> > use Template::Declare::XML;
> > use Jifty::View::Declare schema {
> > namespace cas => 'http://www.yale.edu/tp/cas';
> > default_prefix is 'cas';
> >
> > tag serviceResponse =>
> > is not_empty;
> >
>
> This is a wonderful way to generate XML schema file or even DTD file
> using TD :) Anyone feels like hacking that in? ;)
I want to, but I don't know when I would be able to commit. Maybe sometime
over the next month, but probably not in the next week or two.
>
> > template 'serviceValidate' => sub {
> > my $result = get 'result';
> >
> > xml_decl { version => 1.0, encoding => 'UTF-8' };
> >
>
> I've just committed a patch for the xml_decl sub but the API is now a
> bit more general.
>
> For instance,
>
> xml_decl { 'xml', version => '1.0' };
> xml_decl { 'xml-stylesheet', href => "chrome://global/skin/",
> type => "text/css" };
>
> will produce
>
> <?xml version="1.0"?>
> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
Good idea.
>
> > If there's a namespace prefix "cas" then it can infer this to be
> shorthand for:
> >
> > tag 'cas_serviceResponse' =>
> > prefix 'cas',
> > local_name 'serviceResponse',
> > is not_empty;
> >
>
> To be honest, I'm not very happy with this way of specifying XML
> namespaces since it's not flexible enough. I'm proposing using Perl
> packages to emulate this kind of things. For example, html::div { ...
> }, but we need to define the html package and import symbols into it
> ourselves (sort of).
Yeah, I wasn't precisely pleased with this myself, but it would have been
flexible enough for what I was considering at the time. :-P
The package idea is interesting, I'd be interested to see an example of how
you would declare it and use it.
Cheers,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20070809/0dc0f714/attachment.htm
More information about the jifty-devel
mailing list