Helpers\Assets
2016-07-05 11:46
267 查看
Helpers\Assets
The assets helper is for loading CSS and JS files rather than writing out the full script/link tag for each and every item, instead add them to an array pass to the assets and it output the link/script tags for you.Usage example for loading CSS files:
Assets::css([ 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css', Url::templatePath().'css/style.css', ]);
Will output:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css"> <link href="http://novaframework.dev:8888/templates/default/assets/css/style.css" rel="stylesheet" type="text/css">
Assets has 2 methods css and js, they can take a single value or an array of values.
Example of loading a single js file:
Assets::js(Url::templatePath().'css/app.js');
Both methods have additional parameters other than the file/s:
$cache Default set to false, when set to true the contents will be compressed and compiled into a single files placed within your theme css/js folder.
$refresh Default set to false, set to true to update the cache.
$cachedMins Time in seconds to hold the cache.
Example using a cache:
Assets::css([ 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css', Url::templatePath().'css/style.css', ], true);
Example using a cache and refresh:
Assets::css([ 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css', Url::templatePath().'css/style.css', ], true, true);
相关文章推荐
- alloc、init你弄懂50%了吗?
- 浏览器内核大揭秘
- linux下Scala的安装
- Redis 配置文件详解
- yum搭建lamp或lnmp环境
- 关于Http的七个误解
- shell编程——if语句 if -z -n -f -eq -ne -lt
- jsp自定义标签实例
- Problem B
- Java实现的公平锁
- nginx在linux安装笔记
- c++类型转换
- alloc、init你弄懂50%了吗?
- Https 公钥、私钥、证书
- googleMap本地化(离线)
- php 类中调用另一个类
- 无所不在,见缝插针,这就是营销!
- 多一分的信任和多一分的尊重
- ActiveMQ在C#中的应用示例分析
- Mac 下安装jmeter