ZCML directives
===============

The template directive is a convenient way to register a template
directory.

First we load the meta configuration to make the directive available.

  >>> import repoze.bfg.htmlpage
  >>> from zope.configuration.xmlconfig import xmlconfig, XMLConfig
  >>> XMLConfig('meta.zcml', repoze.bfg.htmlpage)()

Load example template directory configuration.    

  >>> zcml="""
  ... <configure xmlns="http://namespaces.repoze.org/bfg">
  ...    <htmlpage
  ...       directory="%(path)s/templates"
  ...       for="*"
  ...       request_type="*" />
  ... </configure>
  ... """ % locals()

  >>> from StringIO import StringIO
  >>> xmlconfig(StringIO(zcml))

Verify that the layout directory has been registered as a component:

  >>> context = request = object()
  >>> from repoze.bfg.htmlpage.interfaces import ITemplateDirectory
  >>> name, directory = tuple(component.getAdapters(
  ...     (context, request), ITemplateDirectory))[0]

The directory is registered as a component with the path as the name.

  >>> name
  u'.../tests/templates'

Verify that we can get to the layouts.

  >>> from repoze.bfg.htmlpage import get_htmlpage
  >>> get_htmlpage(context, request, 'example')
  <HTMLPage filename=".../tests/templates/example.html">
