GithubHelp home page GithubHelp logo

Comments (8)

pxpm avatar pxpm commented on June 22, 2024 1

Hey @tabacitu !

Excelent job here!

I think @asset is too broad, as you said there is also the Laravel helper.

I am not sure, but I think we should not follow that path and endup with files with @asset(somethin) and asset('other_something') and they represent different things.

I do like the single @loadOnce. It's 100% explicit of what it is doing. Load something once. Who would have guessed ?

Let me know,
Pedro

from assets.

tabacitu avatar tabacitu commented on June 22, 2024 1

Yeah but... I really like @asset() 😅 Even though it might be a BIG mistake...

idk

from assets.

tabacitu avatar tabacitu commented on June 22, 2024

After that, the docs would look like this:

// FOR LOCAL ASSETS

@asset('path/to/file.css')
// will output <link href="{{ asset('path/to/file.css')"> the first time
// then the second time this is called it'll output nothing

@asset('path/to/file.js')
// will output <script src="{{ asset('path/to/file.js')"></script> the first time
// then the second time this is called it'll output nothing

@assetBlock
    <script>
        <!-- Your JS here -->
    </script>

    <!-- OR -->

    <style>
        <!-- Your CSS here -->
    </style>
@endAssetBlock
// will output the contents the first time...
// then the second time it will just output nothing

from assets.

tabacitu avatar tabacitu commented on June 22, 2024

I've just added an @asset() directive in e550896

Looks pretty good...

from assets.

tabacitu avatar tabacitu commented on June 22, 2024

Yeah I kind of like it better... What do you think @pxpm & @promatik ? Which one would you use?

@asset('path/to/file.css')
@asset('path/to/file.js')
@loadCssOnce('path/to/file.css')
@loadJsOnce('path/to/file.css')

from assets.

promatik avatar promatik commented on June 22, 2024

Tough choice.

I love the @asset() version, as you said beautiful, simple, readable.

For those who know what it is 🙃
Because the truth is that it's kind of broad too.

Anyway, those who use the package know what it is ...

I thinks I'd go for asset, and keep loadOnce as an alternative;

@asset('path/to/file.css')
@asset('path/to/file.js')

@asset('unique_name_for_code_block')
    <script>...
    <style>...
@endAsset

and, the alternative;

@loadOnce('path/to/file.css')
@loadOnce('path/to/file.js')

@loadOnce('unique_name_for_code_block')
    <script>...
    <style>...
@endLoadOnce

I think I'd drop loadCssOnce and loadJsOnce 🤷‍♂️

from assets.

tabacitu avatar tabacitu commented on June 22, 2024

Thanks for the feedback guys!

@promatik I'm afraid we can't use @asset() both as an inline directive:

@asset('path/to/file.js`)

AND as a block directive

@asset('some_unique_name')
    <script>
        // smth
    </script>
@endAsset

One Blade directive cannot do both, their signature has to be a little different for us to be able to tell them apart. Best we could do is add a second parameter like @asset('some_id', true) /* bla-bla */ @endAsset but I don't like that, to be honest, not intuitive.


Ok then, I think

  • we'll keep @asset('path/to/file.js'), too, since @promatik and I like it;
  • we'll keep @loadOnce('some_id') /* bla-bla */ @endLoadOnce for blocks, since @pxpm likes it, I don't have a better name for it and we can't use @asset() again;
  • we'll keep @loadJsOnce('path/to/file.js'), @loadCssOnce('path/to/file.css') too, since @pxpm likes them;

That is to say... we keep everything as it already is 😅

Closing 🎉🎉🎉
Thank youu 🙏

from assets.

pxpm avatar pxpm commented on June 22, 2024

@tabacitu just a note, I don't like @loadJsOnce or @loadCssOnce. I think loadOnce and loadOnceBlock would be the ones to go. No different naming and very clear on what they do!

from assets.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.