Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined templates file references incorrect runtime #175

Open
andrewminer opened this issue Feb 14, 2017 · 2 comments
Open

Combined templates file references incorrect runtime #175

andrewminer opened this issue Feb 14, 2017 · 2 comments

Comments

@andrewminer
Copy link

If you use this plugin to create a single downloadable template file from many different pug files, it adds the following line to the top of your template file:

var pug = pug || require('pug/lib/runtime');

That file no longer exists in the main pug package, and when combined with #169, that pretty much means you're screwed since your template file will attempt to reference a non-existent file.

This should be changed to require pug-runtime instead.

@XhmikosR
Copy link
Member

When did this change? Tests are passing so we need more info.

@andrewminer
Copy link
Author

andrewminer commented Feb 19, 2017

I'm not sure when it changed, but I set up a project using grunt-contrib-pug within the past week, and found that this was the case using the latest version of pug from NPM.

Here's the (CoffeeScript) config I used which produced the problem:

        pug:
            pages:
            templates:
                options:
                    client: true
                    compileDebug: false
                    node: true
                    pretty: false
                    inlineRuntimeFunctions: false
                    processName: (f)->
                        f = f.replace DIR_SRC_VIEWS, ""
                        f = f.replace /^\/[^\/]+\/([^.]+)\.pug$/ , "$1"
                        return f
                files:
                    "#{DIR_SRC_VIEWS}/templates.js": ["#{DIR_SRC_VIEWS}/**/*.pug"]

Running this shell script on the output template file makes everything work as expected:

sed -i '' 's/pug\/lib\/runtime/pug-runtime/' "$TEMPLATE_FILE"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants