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

Assets are rendered several times #44

Open
hammat opened this issue Jul 10, 2013 · 4 comments
Open

Assets are rendered several times #44

hammat opened this issue Jul 10, 2013 · 4 comments

Comments

@hammat
Copy link

hammat commented Jul 10, 2013

When using Casset in partials, it renders the same file several times.
Then it causes conflicts for javascript.

Shouldn't Casset render only once each file to avoid these conflicts?

@canton7
Copy link
Owner

canton7 commented Jul 10, 2013

Casset renders each group only once, by disabling a group after it's been rendered. This means you must be adding the same file to the same group multiple times? Yeah I can see that going wrong. I think I'd prefer to prevent the second instance of the file being added to the group, if that makes sense?

@hammat
Copy link
Author

hammat commented Jul 10, 2013

Yes, the file is hadded several times in the same group (js by default).
I had a look in add_asset to do it inside but because of multidimensional arrays, I didn't wanted to make the code too complex.

I can have another look if you want. Still it might be more overkill.

@canton7
Copy link
Owner

canton7 commented Jul 13, 2013

Hmm? I was thinking of something along the lines of

if (in_array($files, static::$groups[$type][$group]['files']))
    return;

around about line 555?

@hammat
Copy link
Author

hammat commented Aug 22, 2013

Hey sorry mate for my late answer.
It's a way nicer solution you have, I agree.

It looks like your in_array condition works properly when added just before the array_push.

if (!in_array($files, static::$groups[$type][$group]['files']))
    array_push(static::$groups[$type][$group]['files'], $files);

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