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

Document the new Asset component + framework changes #4982

Closed
3 of 4 tasks
javiereguiluz opened this issue Feb 10, 2015 · 5 comments
Closed
3 of 4 tasks

Document the new Asset component + framework changes #4982

javiereguiluz opened this issue Feb 10, 2015 · 5 comments
Labels
actionable Clear and specific issues ready for anyone to take them. Asset hasPR A Pull Request has already been submitted for this issue.
Milestone

Comments

@javiereguiluz
Copy link
Member

javiereguiluz commented Feb 10, 2015

The new Asset component has been merged in symfony/symfony#13234.

Todos:

1. Changes in configuration

# OLD configuration
framework:
    templating:
        assets_version: 'v5'
        assets_version_format: '%%s?version=%%s'
        assets_base_urls:
            http: ['http://cdn.example.com']
            ssl:  ['https://secure.example.com']
        packages:
            # ...

# NEW configuration
framework:
    assets:
        version: 'v5'
        version_format: '%%s?version=%%s'
        base_path: ~
        base_urls: ['http://cdn.example.com', 'https://secure.example.com']
        packages:
            # ...

2. Changes in Twig templates

{{ asset() }} function is the same as before, but now it only allows to set two arguments:

{# Common case: no package name #}
{{ asset('logo.png') }}

{# When using packages #}
{{ asset('logo.png', 'images') }}

This means that absolute and version arguments are no longer available:

{# BEFORE #}
{{ asset('logo.png', absolute = true) }}

{# AFTER #}
{{ absolute_url(asset('logo.png')) }}


{# BEFORE #}
{{ asset('logo.png', version = 'v5') }}

{# AFTER #}
{# relative URLs - do nothing (version is automatically appended) #}
{{ asset('logo.png') }}

{# absolute URLs - get the version with asset_version() and append it manually #}
{{ absolute_url(asset('logo.png')) ~ '?' ~ asset_version('logo.png') }}

3. Other changes

  • The asset*() functions are now defined in the Twig Bridge instead of the Twig Bundle.

4. Lastly, I have a question when using Asset component in a Symfony application: How can I use a custom version strategy in a Symfony application?

@xabbuh
Copy link
Member

xabbuh commented Feb 10, 2015

Thank you for taking care of this @javiereguiluz

@xabbuh xabbuh added the actionable Clear and specific issues ready for anyone to take them. label Feb 10, 2015
@xabbuh xabbuh added this to the 2.7 milestone Feb 10, 2015
@xabbuh xabbuh added the Asset label Feb 10, 2015
@xabbuh
Copy link
Member

xabbuh commented Feb 10, 2015

The component's readme can be used as a starting point for this.

@wouterj wouterj added the hasPR A Pull Request has already been submitted for this issue. label Feb 19, 2015
weaverryan added a commit that referenced this issue Mar 14, 2015
…viereguiluz)

This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #4987).

Discussion
----------

Added the documentation for the new Asset component

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | 2.7+
| Fixed tickets | #4982

This PR only adds the "Symfony-agnostic" documentation. After this doc is merged, we have to update the rest of the Symfony documentation with the following changes:

-----

**1. Changes in configuration**

```yaml
# OLD configuration
framework:
    templating:
        assets_version: 'v5'
        assets_version_format: '%%s?version=%%s'
        assets_base_urls:
            http: ['http://cdn.example.com']
            ssl:  ['https://secure.example.com']
        packages:
            # ...

# NEW configuration
framework:
    assets:
        version: 'v5'
        version_format: '%%s?version=%%s'
        base_path: ~
        base_urls: ['http://cdn.example.com', 'https://secure.example.com']
        packages:
            # ...
```

**2. Changes in Twig templates**

`{{ asset() }}` function is the same as before, but now it only allows to set two arguments:

```twig
{# Common case: no package name #}
{{ asset('logo.png') }}

{# When using packages #}
{{ asset('logo.png', 'images') }}
```

This means that `absolute` and `version` arguments are no longer available:

```twig
{# BEFORE #}
{{ asset('logo.png', absolute = true) }}

{# AFTER #}
{{ absolute_url(asset('logo.png')) }}

{# BEFORE #}
{{ asset('logo.png', version = 'v5') }}

{# AFTER #}
{# relative URLs - do nothing (version is automatically appended) #}
{{ asset('logo.png') }}

{# absolute URLs - get the version with asset_version() and append it manually #}
{{ absolute_url(asset('logo.png')) ~ '?' ~ asset_version('logo.png') }}
```

**3. Other changes**

  * The `asset*()` functions are now defined in the Twig Bridge instead of the Twig Bundle.
  * ...

-----

Lastly, I have a question when using Asset component in a Symfony application: How can I use a custom version strategy in a Symfony application?

Commits
-------

7ab379a Lots of fixes and rewordings
9e8de96 Fixed RST syntax issues
5ca85d1 Fixed some RST syntax issues
17269a3 Moved the component documentation to its own folder
fab3c89 Fixed a lot of errors and added an introduction
49548b3 Tweaked documentation and added links to API methods/classes
76b8bea Added a missing link reference
d39b26e Minor rewording
6d367b1 Added the documentation for the new Asset component
@weaverryan weaverryan changed the title Document the new Asset component Document the new Asset component + framework changes Mar 14, 2015
weaverryan added a commit that referenced this issue Mar 22, 2015
This PR was merged into the 2.7 branch.

Discussion
----------

Proofreading tweaks to asset component

This follows after #4987 - all pretty minor.

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | no
| Applies to    | 2.7+
| Fixed tickets | Works towards #4982

Commits
-------

59325ee Changes thanks to WouterJ and xabbuh
110efab [#4987] Proofreading tweaks to asset component
@wouterj wouterj closed this as completed Apr 3, 2015
@xabbuh
Copy link
Member

xabbuh commented Apr 3, 2015

Reopening as I think we still have to cover the other three items.

@wouterj Please let me know if you disagree.

@xabbuh xabbuh reopened this Apr 3, 2015
@wouterj
Copy link
Member

wouterj commented Apr 3, 2015

Oh, I was to quick. ✋

Thanks for reviewing my actions, @xabbuh.

@stof
Copy link
Member

stof commented Aug 20, 2015

Regarding changes in Twig templates, assets_version is deprecated in favor of asset_version which has a different signature (custom version strategies could have a different version per path)

xabbuh added a commit that referenced this issue May 9, 2016
…z, WouterJ)

This PR was merged into the 2.7 branch.

Discussion
----------

[2.7] Update Twig docs for asset features

Finishes #5171

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.7+
| Fixed tickets | #4982 (partially)

Commits
-------

0cd7e6c Correctly document new twig functions
bc18ff1 Updated Twig template to take into account asset() function changes
@wouterj wouterj closed this as completed Jul 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. Asset hasPR A Pull Request has already been submitted for this issue.
Projects
None yet
Development

No branches or pull requests

4 participants