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

symfony 7 documentation #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Guteres007
Copy link

In Symfony 7 doesnt working default asset function:

<script type="text/javascript" src="{{ asset('typescript/app.ts') }}"></script>

I solved it with:
{{ importmap('typescript/app') }}

@maelanleborgne
Copy link
Contributor

Hi, thank you for the request 🙏
I tried the original example from the doc myself and it work correctly with symfony 7.0 as well as 7.1, so I don't think that having different approaches depending on symfony version is the way to go.

But obviously the doc should be improved.
I see 3 use-case but I may be mistaken (@WebMamba maybe you could advise us on the best practices ?).

  1. You're approach is good when your app has a typescript file as an entrypoint. You define it in importmap.php and then you only call the importmap function once in your twig template.
  2. If your your typescript file isn't supposed to be an entrypoint, you can just import what you need from your original entrypoint :
// assets/app.js
import {MyTypeScriptClass} from "./typescript/my-ts-file.ts"
  1. If you just want to load a raw script, the example from the doc should work.

Now I don't know if we should showcase all these use-cases, some advises from the ux community would be appreciated.

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 this pull request may close these issues.

2 participants