-
Notifications
You must be signed in to change notification settings - Fork 42
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
Inline scripts #36
Comments
@fisharebest I have no plan to include such feature as it would need a heavy modification of the code. May be for the future when I refactor the code to be more object oriented instead of a bunch of array functions :/ |
FYI, this is how I achieve it.
|
Well, when I said it would involve a heavy modification of the code I had in mind integrating the inline scripts with the javascript assets workflow (respecting the "First In First Out' policy, don't duplicate assets, pipeline support, dependencies, etc...). Your approach is much simpler, defining a different flow for inline JS assets, independent from normal JS assets. In that case it may have a place. I'll look into it. Just one quick note, in order to preserve original function signature you better change last function to
|
As I said originally, I have been using this technique which I picked up from the Zend Framework. However, I've been re-examining exactly how I've been using it - and pretty much everything I'm doing could be implemented more cleanly using better markup and static scripts. So, if you were looking into it, there is no need ;-) |
+1 |
Hello, in laravel 5 where I put the code? thank you in advance class Assets extends \Stolz\Assets\Manager {
} |
@erickmonteiro, you can put it anywhere you want as long as the place is listed in your Since in L5 the If you still want to use the
|
Is this something incorporated into the library yet, or do we still need to extend it as shown here? Being able to mix file and URL-based assets with in-line JS is an incredibly usefult feature, and a must-have for my general use (how other's mileage varies, I don't know). |
@judgej I do this via View::composer |
@hotrush what part of the problem does the View::composer solve? It sounds interesting, but so far as I can see, it is a technique that avoids the need to fetch a value in a controller (or a parent view) and explicitly pass it into a view. I'm guessing it is how the |
@judgej in my case i need to pass some data from php to javascript (but it can be modified as you want).
in
in layout view
script composer view (it may bind key->value data, but can be modified for your purposes)
and in controllers method i do next
|
Thanks, that makes sense. So here the controllers throw together key/value data, and the View::composer is used to make sure that key/value data is available to any JS running on the page. Your static JS assets then know what data to look for, and how to use it. I think I would want to pass in fragments of JS too - more than just variables - and some of those fragments would come from sub-views within the page, but this would certainly work for that too. Edit: sorry if this is turning into a support forum thread - wasn't my intention and I'll stop now :-) |
+1 With a little modification : Translated to stolz/assets, it would look something like this:
When you come to render the data, you would get this:
with |
@Nuranto please take a look at Laravel Blade stacks. They allow you to accomplish the inline assets feature very easily. |
Yes, I'm using that already. |
As well as external resources (files), it is often useful to manage inline resouces (scripts) at the same time.
For example, ZendFramework offers this feature via its headScript->appendScript() and headScript->appendFile() methods. I have coded something similar in many projects.
Translated to stolz/assets, it would look something like this:
When you come to render the data, you would get this:
We collect the inline scripts, and render them after the external scripts.
Does this sort of feature have a place in this project?
The text was updated successfully, but these errors were encountered: