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
93aaeba9
Commit
93aaeba9
authored
Dec 04, 2013
by
Kartik Visweswaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doc proofing mistakes & typos corrected
parent
4df9b6cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
assets.md
docs/guide/assets.md
+7
-8
No files found.
docs/guide/assets.md
View file @
93aaeba9
...
@@ -3,7 +3,7 @@ Managing assets
...
@@ -3,7 +3,7 @@ Managing assets
An asset in Yii is a file that is included into the page. It could be CSS, JavaScript or
An asset in Yii is a file that is included into the page. It could be CSS, JavaScript or
any other file. Framework provides many ways to work with assets from basics such as adding
`<script src="`
tag
any other file. Framework provides many ways to work with assets from basics such as adding
`<script src="`
tag
for a file that is
[
handled by View
](
view.md
)
section to advanced usage such as pu
s
blishing files that are not
for a file that is
[
handled by View
](
view.md
)
section to advanced usage such as publishing files that are not
under webserve document root, resolving JavaScript dependencies or minifying CSS.
under webserve document root, resolving JavaScript dependencies or minifying CSS.
Declaring asset bundle
Declaring asset bundle
...
@@ -13,7 +13,7 @@ In order to publish some assets you should declare an asset bundle first. The bu
...
@@ -13,7 +13,7 @@ In order to publish some assets you should declare an asset bundle first. The bu
directories to be published and their dependencies on other asset bundles.
directories to be published and their dependencies on other asset bundles.
Both basic and advanced application templates contain
`AppAsset`
asset bundle class that defines assets required
Both basic and advanced application templates contain
`AppAsset`
asset bundle class that defines assets required
applicationwide. Let's review basic application asset bundle class:
application
wide. Let's review basic application asset bundle class:
```
php
```
php
class
AppAsset
extends
AssetBundle
class
AppAsset
extends
AssetBundle
...
@@ -41,7 +41,7 @@ is an alias that corresponds to your website base URL such as `http://example.co
...
@@ -41,7 +41,7 @@ is an alias that corresponds to your website base URL such as `http://example.co
In case you have asset files under non web accessible directory, that is the case for any extension, you need
In case you have asset files under non web accessible directory, that is the case for any extension, you need
to additionally specify
`$sourcePath`
. Files will be copied or symlinked from source bath to base path prior to being
to additionally specify
`$sourcePath`
. Files will be copied or symlinked from source bath to base path prior to being
registered. In case source path is used
`baseUrl`
is generated automatically at the time of publising asset bundle.
registered. In case source path is used
`baseUrl`
is generated automatically at the time of publis
h
ing asset bundle.
Dependencies on other asset bundles are specified via
`$depends`
property. It is an array that contains fully qualified
Dependencies on other asset bundles are specified via
`$depends`
property. It is an array that contains fully qualified
names of bundle classes that should be published in order for this bundle to work properly.
names of bundle classes that should be published in order for this bundle to work properly.
...
@@ -50,7 +50,7 @@ Here `yii\web\YiiAsset` adds Yii's JavaScript library while `yii\bootstrap\Boots
...
@@ -50,7 +50,7 @@ Here `yii\web\YiiAsset` adds Yii's JavaScript library while `yii\bootstrap\Boots
[
Bootstrap
](
http://getbootstrap.com
)
frontend framework.
[
Bootstrap
](
http://getbootstrap.com
)
frontend framework.
Asset bundles are regular classes so if you need to define another one, just create alike class with unique name. This
Asset bundles are regular classes so if you need to define another one, just create alike class with unique name. This
class can be placed anywhere but the convention for it is to be under
`assets`
directory of the applica
it
on.
class can be placed anywhere but the convention for it is to be under
`assets`
directory of the applica
ti
on.
Registering asset bundle
Registering asset bundle
------------------------
------------------------
...
@@ -88,7 +88,7 @@ return [
...
@@ -88,7 +88,7 @@ return [
];
];
```
```
In the above we're adding asset bundle definitions to
`bun
ld
es`
property of asset manager. Keys there are fully
In the above we're adding asset bundle definitions to
`bun
dl
es`
property of asset manager. Keys there are fully
qualified class paths to asset bundle classes we want to override while values are key-value arrays of class properties
qualified class paths to asset bundle classes we want to override while values are key-value arrays of class properties
and corresponding values to set.
and corresponding values to set.
...
@@ -217,7 +217,7 @@ Using asset converter
...
@@ -217,7 +217,7 @@ Using asset converter
Instead of using CSS and JavaScript directly often developers are using their improved versions such as LESS or SCSS
Instead of using CSS and JavaScript directly often developers are using their improved versions such as LESS or SCSS
for CSS or Microsoft TypeScript for JavaScript. Using these with Yii is easy.
for CSS or Microsoft TypeScript for JavaScript. Using these with Yii is easy.
First of all, corresponding compression tools should be installed and should be availabe from where
`yii`
console
First of all, corresponding compression tools should be installed and should be availab
l
e from where
`yii`
console
bootstrap file is. The following lists file extensions and their corresponding conversion tool names that Yii converter
bootstrap file is. The following lists file extensions and their corresponding conversion tool names that Yii converter
recognizes:
recognizes:
...
@@ -267,4 +267,4 @@ In order to adjust conversion tool call parameters or add new ones you can use a
...
@@ -267,4 +267,4 @@ In order to adjust conversion tool call parameters or add new ones you can use a
In the above we've left two types of extra file extensions. First one is
`less`
that can be specified in
`css`
part
In the above we've left two types of extra file extensions. First one is
`less`
that can be specified in
`css`
part
of an asset bundle. Conversion is performed via running
`lessc {from} {to} --no-color`
where
`{from}`
is replaced with
of an asset bundle. Conversion is performed via running
`lessc {from} {to} --no-color`
where
`{from}`
is replaced with
LESS file path while
`{to}`
is replaced with target CSS file path. Second one is
`ts`
that can be specified in
`js`
part
LESS file path while
`{to}`
is replaced with target CSS file path. Second one is
`ts`
that can be specified in
`js`
part
of an asset bundle. The command that is run during conversion is in the same format that is used for
`less`
.
of an asset bundle. The command that is run during conversion is in the same format that is used for
`less`
.
\ No newline at end of file
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