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

Marko Taglib: Cannot read property 'replace' of undefined #1726

Open
hedav85 opened this issue Aug 4, 2021 · 3 comments
Open

Marko Taglib: Cannot read property 'replace' of undefined #1726

hedav85 opened this issue Aug 4, 2021 · 3 comments
Labels
type:unverified bug A bug report that has not been verified

Comments

@hedav85
Copy link

hedav85 commented Aug 4, 2021

Marko Version: 5.14.2

Details

If I render a marko template I got the error below from marko taglib

application.js:630 TypeError: Cannot read property 'replace' of undefined
    at render (/projectPath/node_modules/@lasso/marko-taglib/taglib/slot-tag.js:92:57)
    at render (/projectPath/node_modules/@lasso/marko-taglib/taglib/head-tag.js:16:3)
    at renderTagHelper (/projectPath/node_modules/marko/dist/runtime/helpers/render-tag.js:15:77)
    at _marko_template._.t (/projectPath/.../login/index.marko:44:26)
    at renderer (/projectPath/node_modules/marko/dist/runtime/components/renderer.js:218:5)
    at safeRender (/projectPath/node_modules/marko/dist/runtime/renderable.js:7:5)
    at Template.render (/projectPath/node_modules/marko/dist/runtime/renderable.js:139:14)
    at ServerResponse.renderMarkoTemplate [as marko] (/projectPath/node_modules/@marko/express/dist/cjs/index.js:20:10)
    at AuthenticationRouter.<anonymous> (/projectPath/.../AuthenticationRouter.js:86:29)

I use require('@marko/compiler/register'); to load marko template and then I require the template via const template = require(templatePath).default;

And then I do res.marko(template, {...} to render and send it to the client.

Your Environment

NodeJS 16.6.1
"@lasso/marko-taglib": "^2.0.3",
"@marko/express": "^1.0.0",
"lasso": "^3.4.0",
"lasso-less": "^4.0.0",
"lasso-marko": "^3.0.1",
"lasso-minify": "1.0.4",
"lasso-minify-css": "1.1.4",
"marko": "^5.14.2",

Is there something missing or I'm doing something wrong?
In Marko 4 it works fine. Could it depent on the change from node-require to @marko/compiler/register?

@hedav85 hedav85 added the type:unverified bug A bug report that has not been verified label Aug 4, 2021
@JPritchard9518
Copy link

I am having the same issue. When updating to Marko 5 I get the console warning message:
Using "marko/node-require" has been replaced with "@marko/compiler/register".
So I changed marko/node-require to @marko/compiler/register.
Now I get a warning that says:
Using "marko/compiler" has been deprecated, please upgrade to the "@marko/compiler" module.
Even though I am using @marko/compiler...

After making that change and loading a page I get the error: TypeError: Cannot read property 'replace' of undefined

@DylanPiercey
Copy link
Contributor

@JPritchard9518 @hedav85 it turns out that @lasso/marko-taglib is relying on some meta data being attached to the template that is not added via the newer @marko/compiler/register by default.

You can opt into adding that meta data again by using:

require("@marko/compiler/register")({ meta: true })

I do think we should figure out a better way to do this in @lasso/marko-taglib though.

@hedav85
Copy link
Author

hedav85 commented Feb 18, 2022

@DylanPiercey with the meta flag it works 👍 So the issue is solved for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:unverified bug A bug report that has not been verified
Projects
None yet
Development

No branches or pull requests

3 participants