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

v3 - Commas added in body #31

Closed
mparker11 opened this issue Sep 8, 2018 · 1 comment
Closed

v3 - Commas added in body #31

mparker11 opened this issue Sep 8, 2018 · 1 comment

Comments

@mparker11
Copy link

I've been using v2 and when I first set it up, I remember having one comma appended to the body after mapping the assets. This was fixed by adding .join('') to the ended of the return statement.

Now after upgrading to v3, I am getting the same treatment, but this time it is appending four commas and I can't get rid of them. Basically my markup looks like this at render:

<body>
    ,,
    <div id="app"></div>
    ,,
</body>

Any idea what's going on?

@mparker11
Copy link
Author

mparker11 commented Oct 19, 2018

For anyone who needs the answer to this, it was a matter of breaking down the docs' basic example. The docs said to do this inside the <body>:

${assets.map(src => `<script src="${src}"></script>`)}

but I ended up having to manipulate it since it returns an array -- and an array includes commas. There is also a special check to make sure that it only grabs JS files (courtesy of docs from v2).

${
    Object.keys(assets).map((key) => {
         let jsAssets = assets[key].filter((src) => src.endsWith('.js'));
         let mapped = jsAssets.map((src) => {
             return `<script src="/${src}"></script>`
         });
         return mapped[0]
     }).join('')
}

I had been doing this for v2, but now the difference is there is an extra array in v3, thus I had to break it down to return mapped[0] rather than returning the map itself. Also, notice the join added at the end, which removes the commas from the returned array.

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