Skip to content

File Compiler modules do not work when ProcessWire namespace is present #882

@Toutouwai

Description

@Toutouwai

Short description of the issue

ProcessWire v3.0 introduced a new type of module: File Compiler modules that extend the FileCompilerModule class. It also included a new module FileCompilerTags.

This issue is about the fact that File Compiler modules do not work when template files include the ProcessWire namespace.

To illustrate with FileCompilerTags...

basic-page.php without namespace:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title><?php echo $page->title; ?></title>
        <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" />
    </head>
    <body>
        <h1>{title}</h1>
        <?php if($page->editable()) echo "<p><a href='$page->editURL'>Edit</a></p>"; ?>
    </body>
</html>

Result:
2019-05-18_113200

basic-page.php with namespace:

<?php namespace ProcessWire; ?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title><?php echo $page->title; ?></title>
        <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" />
    </head>
    <body>
        <h1>{title}</h1>
        <?php if($page->editable()) echo "<p><a href='$page->editURL'>Edit</a></p>"; ?>
    </body>
</html>

Result:
2019-05-18_113309

The introductory blog post, the comments in FileCompilerModule.php, and the comments in FileCompilerTags.module do not mention that it is necessary for the ProcessWire namespace to be absent. And IMO it shouldn't be necessary - a person might include the ProcessWire namespace to get code completion and documentation in their IDE and this shouldn't impact on whether they can use File Compiler modules.

Setup/Environment

  • ProcessWire version: 3.0.131

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions