예제 #1
0
 public function test_inline()
 {
     $assets = Assets::factory('test_name')->process(FALSE)->css('test.css')->js('test.js');
     $inline = $assets->inline();
     $this->assertContains('.test { display: block; }', $inline);
     $this->assertContains('var test;', $inline);
 }
예제 #2
0
 protected function _load_assets($config)
 {
     if (isset($config['head'])) {
         Assets::factory('head')->load($config['head']);
     }
     if (isset($config['body'])) {
         Assets::factory('body')->load($config['body']);
     }
 }
예제 #3
0
파일: Gear.php 프로젝트: brussens/cogear2
 /**
  * Конструктор
  */
 public function __construct($config)
 {
     parent::__construct($config);
     if (self::$is_init) {
         return;
     }
     // Важно повесить хук именно таким образом, чтобы информация выводилась до остальных скриптов
     hook('head', array($this, 'hookHead'));
     $this->js = Assets::factory('scripts', config('assets.js'));
     $this->css = Assets::factory('styles', config('assets.css'));
     self::$is_init = TRUE;
 }
예제 #4
0
 /**
  * Pre-compile js files
  * 
  * @access protected
  * @return void
  */
 protected function _run_js()
 {
     $filename = Arr::get($this->_config, 'compile_config_filename', 'asset_defs');
     $config = Kohana::$config->load('js');
     $js_array = [];
     $js_settings = Kohana::$config->load($filename . '.js') ?: [];
     $js_settings = [];
     foreach ($config as $key => $value) {
         // Create new assets object
         $asset = Assets::factory()->js($value)->force_recompile($this->_force_recompile);
         if ($hash = $asset->get('js', true)) {
             $js_array[$key] = $hash;
         }
     }
     if (!empty($js_array)) {
         if ($js_settings !== $js_array) {
             $return_array = $js_array;
             // Cleanup
             $files = glob(DOCROOT . $this->_compile_paths['js'] . '*');
             foreach ($files as $file) {
                 preg_match('/\\/([a-zA-Z0-9_]+).js$/', $file, $matches);
                 if ($match = Arr::get($matches, 1)) {
                     if (!in_array($match, $js_array)) {
                         @unlink($file);
                     }
                 }
             }
         }
     }
     return $return_array;
 }