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

How to render js files in views #28

Open
mahmoudIsProgramer opened this issue Aug 27, 2022 · 1 comment
Open

How to render js files in views #28

mahmoudIsProgramer opened this issue Aug 27, 2022 · 1 comment
Assignees
Labels
help wanted Extra attention is needed

Comments

@mahmoudIsProgramer
Copy link

Hello thecodeholic ,
thanks a lot for the the great course and the lovely educational materials . in layouts/main.php there exist {{content}} and as i understood it's to replace the content of view , how can i make similar to this but for js files , i want to load js file in my view without putting it in layouts/main.php beofr tag

@thecodeholic
Copy link
Owner

thecodeholic commented Sep 25, 2022

That is not straight forward and directly possible at the moment.
One Simple solution will be

  1. to extend Application class
  2. Use the new Application class into public/index.php
  3. Add $js and $css arrays into extended class
  4. From controllers's method put your JavaScript or CSS files into new Application class $js and $css
  5. Iterate over them into layout/main.php and render them.

@mahmoudIsProgramer Let me know if this helps.

@thecodeholic thecodeholic self-assigned this Sep 25, 2022
@thecodeholic thecodeholic added the help wanted Extra attention is needed label Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants