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

How to compile from pug files that uses pug locals? #108

Open
7iomka opened this issue Jul 21, 2021 · 1 comment
Open

How to compile from pug files that uses pug locals? #108

7iomka opened this issue Jul 21, 2021 · 1 comment

Comments

@7iomka
Copy link

7iomka commented Jul 21, 2021

[easygettext] could not read: './dev/pages/base-variables.pug' using acorn as parser
Trace: TypeError: ./dev/pages/base-variables.pug:13
    11| - let langInUrl = false
    12| - let appLinkIconSuffix = ''
  > 13| -
    14|         let languages = Object.keys(isoLanguages).filter(code => {
    15|                 return _.includes(supportedLanguages, code);
    16|         }).map(code => {

Cannot read property 'includes' of undefined
    at eval (eval at wrap (/Users/7iomka/Desktop/Projects/Core_new/core_new/node_modules/pug/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:752:11)

My locals and pug build looks like this

const _ = require('lodash');
const locals = { _, ... }
...

 // Compile the source code of file with compilation option from pug-config
      const compiledFunction = pug.compileFile(source, options);
      // Render a set of data
      const html = compiledFunction({
        ...locals,
        langToRender: lang,
        variablesToRender: locals.includeVariables(lang),
      });
@7iomka
Copy link
Author

7iomka commented Jul 21, 2021

How I see you pass your own locals (2nd parameter), and user defined is skipped.
Need somehow to make possible to extend it with user-defined.

templateData = pug.render(data, {
filename: filename,
pretty: true,
require: () => {
},
}).trim();

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

1 participant