Skip to content

Compiler's method getContent() does not pass $file parameter to any filter #132

Description

@MartinPavlik

This causes that cssUrlsFilter does not work.

I believe, the problem is here: Compiler line 168

I use following fix that works fine for me:

    /**
     * Get joined content of all files
     * @param array $files
     * @return string
     */
    public function getContent(array $files = null)
    {
        if ($files === null) {
            $files = $this->collection->getFiles();
        }
        // load content
        $result = '';
        foreach ($files as $file) {
            $fileContent = PHP_EOL . $this->loadFile($file);
            foreach($this->filters as $filter) {
                $fileContent = call_user_func($filter, $fileContent, $this, $file);
            }
            $result .= $fileContent;
        }
        return $result;
    }

I can create a pull request, but I can't pass tests due to:

1) WebLoader\Test\CompilerTest::testGeneratingAndFilters
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '-
-a:cba,
-b:fed,
+a:cba,-
+a:cba,-
+b:fed,-
+b:fed,-
 c:ihg,-
-a:cba,
-b:fed,
 c:ihg,'

https://forum.nette.org/cs/2578-addon-webloader-extras-webloader?p=7#p165520

@janmarek

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions