0

I have been wondering if it is possible to add a parameter for the asset twig function like this

#config.yml
...
framework:
   templating:
      parameters: 
         key: value
OR
twig:
   parameters:
      key: value
...

And in the twig file use asset like this

# twig file
<script src="{{ asset('/file/path', key) }}"></script>

And will regenerate

<script src="/file/path?key=value"></script>

I know i can create a macro to do this but i want to know if there are another way.

Thank for your reply

2

1 Answer 1

0

Assets are generally static files and not dynamic scripts, are you sure you're doing the right thing? If you have an asset that accepts a parameter maybe it should be a in a controller with a route defined so you can act on it within code and a {{ path('...', {key: value}) }}

Otherwise, The only thing assetic lets you do is auto-append a version number to assets using assets_version

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.