Author image David E. Wheeler


Template::Declare::Bricolage - Perlish XML Generation for Bricolage's SOAP API


  use Template::Declare::Bricolage;

  say bricolage {
      workflow {
          attr        { id => 1027     };
          name        { 'Blogs'        }
          description { 'Blog Entries' }
          site        { 'Main Site'    }
          type        { 'Story'        }
          active      { 1              }
          desks  {
              desk { attr { start   => 1 }; 'Blog Edit'    }
              desk { attr { publish => 1 }; 'Blog Publish' }


It can be a lot of work generating XML for passing to the Bricolage SOAP interface. After experimenting with a number of XML-generating libraries, I got fed up and created this module to simplify things. It's a very simple subclass of Template::Declare that supplies a functional interface to templating your XML. All the XML elements understood by the Bricolage SOAP interface are exported from Template::Declare::TagSet::Bricolage, which you can use independent of this module if you require a bit more control over the output.

But the advantage to using Template::Declare::Bricolage is that it sets up a bunch of stuff for you, so that the usual infrastructure of setting up the templating environment, outputting the top-level <assets> element and the XML namespace, is just handled. You can just focus on generating the XML you need to send to Bricolage.

And the nice thing about Template::Declare's syntax is that it's, well, declarative. Just use the elements you need and it will do the rest. For example, the code from the Synopsis returns:

    <assets xmlns="">
      <workflow id="1027">
        <description>Blog Entries</description>
        <site>Main Site</site>
          <desk start="1">Blog Edit</desk>
          <desk publish="1">Blog Publish</desk>

bricolage {}

In addition to all of the templating functions exported by Template::Declare::TagSet::Bricolage, Template::Declare::Bricolage exports one more function, bricolage. This is the main function that you should use to generate your XML. It starts the XML document with the XML declaration and the top-level <assets> element required by the the Bricolage SOAP API. Otherwise, it simply executes the block passed to it. That block should simply use the formatting functions to generate the XML you need for your assets. That's it.


This module is stored in an open GitHub repository, Feel free to fork and contribute!

Please file bug reports at


David E. Wheeler <>

Copyright and License

Copyright (c) 2009 David E. Wheeler. Some Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.