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

[v1] loadOnce() as the single directive #6

Closed
tabacitu opened this issue Nov 2, 2021 · 1 comment · Fixed by #8
Closed

[v1] loadOnce() as the single directive #6

tabacitu opened this issue Nov 2, 2021 · 1 comment · Fixed by #8

Comments

@tabacitu
Copy link
Member

tabacitu commented Nov 2, 2021

Pedro said - what if we only have:

// if there's a file extension... it's a file
// (alternatively, if it has dots or slashes... it's a path or URL)
@loadOnce('path/to/js.js')
@loadOnce('path/to/css.css')

// if it doesn't have an extension... it's a block
@loadOnce('unique_name_for_code_block')
    <script>
        <!-- Your JS here -->
    </script>

    <!-- OR -->

    <style>
        <!-- Your CSS here -->
    </style>
@endLoadOnce
@promatik
Copy link
Collaborator

promatik commented Nov 4, 2021

This looks promising!

I think we should not rely on dots or slashes, because a path may be just @loadOnce('main.js'), we should rely on the name ending with .js or .css, and expect users to not use ids that look like a file name.

Maybe we could also check if file exists, but it's more "expensive" probably and in a situation where the file mistakenly doesn't exist it would be, wrongly, expect an ending block – so it's not a good idea.

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

Successfully merging a pull request may close this issue.

2 participants