Fix template handling for library modules

The proper template structure was not being examined for files defined
in library modules.

Fixes #85