Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
be78c434
Commit
be78c434
authored
Jun 25, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guide about conditional comments and JS position
fixes #4053
parent
c8299697
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
1 deletion
+39
-1
structure-assets.md
docs/guide/structure-assets.md
+39
-1
No files found.
docs/guide/structure-assets.md
View file @
be78c434
...
@@ -76,7 +76,7 @@ class can be placed anywhere but the convention for it is to be under `assets` d
...
@@ -76,7 +76,7 @@ class can be placed anywhere but the convention for it is to be under `assets` d
Additionally you may specify
`$jsOptions`
,
`$cssOptions`
and
`$publishOptions`
that will be passed to
Additionally you may specify
`$jsOptions`
,
`$cssOptions`
and
`$publishOptions`
that will be passed to
[
[yii\web\View::registerJsFile()
]
],
[
[yii\web\View::registerCssFile()
]
] and
[
[yii\web\AssetManager::publish()
]
]
[
[yii\web\View::registerJsFile()
]
],
[
[yii\web\View::registerCssFile()
]
] and
[
[yii\web\AssetManager::publish()
]
]
respectively during registering and publising an asset.
respectively during registering and publising an asset.
For more details on this see
[
Setting special options
](
#setting-special-options
)
.
[
alias
]:
basics.md#path-aliases
"Yii Path alias"
[
alias
]:
basics.md#path-aliases
"Yii Path alias"
...
@@ -135,6 +135,44 @@ AppAsset::register($this->view);
...
@@ -135,6 +135,44 @@ AppAsset::register($this->view);
copying them over.
copying them over.
Setting special options <a name="setting-special-options"></a>
-----------------------
Asset bundles allow setting specific options for the files to be published.
This can be done by configuring the
[
[yii\web\AssetBundle::$jsOptions|$jsOptions
]
],
[
[yii\web\AssetBundle::$cssOptions|$cssOptions
]
] or
[
[yii\web\AssetBundle::$publishOptions|$publishOptions
]
]
property of the asset bundle.
Some of these options are described in the following:
-
For setting conditional comments for your CSS files you can set the following option:
```
php
public
$cssOptions
=
[
'condition'
=>
'lte IE9'
];
```
This will result in a link tag generated as follows: `
<!--
[
if
lte
IE9
]
><
link
.../><!
[
endif
]
-->
`.
You can only define one condition per asset bundle, if you have multiple files with different conditions,
you have to define multiple assets bundles.
- For javascipt files you can define the position where they should be added in the HTML.
You can choose one of the following positions:
- [[yii\web\View::POS_HEAD]]: in the head section
- [[yii\web\View::POS_BEGIN]]: at the beginning of the body section
- [[yii\web\View::POS_END]]: at the end of the body section. This is the default value.
Example for putting all javascript files to the end of the body.
```
php
public
$jsOptions
=
[
'position'
=>
\yii\web\View
::
POS_END
];
```
This option is also reflected when resolving dependencies.
- For further javascript options, see [[yii\helpers\Html::jsFile()]].
Overriding asset bundles
Overriding asset bundles
------------------------
------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment