Esempio n. 1
0
 public function testGrunt()
 {
     $groups = new ResourceGroups();
     $groups->addGroup('grunt_scss');
     $res = new StyleSheetResourceManager($groups, function (StyleSheetResource $res) {
         $combine = new StyleSheetCombineFiles();
         $combine->setInputDir(__DIR__)->setOutputDir(__DIR__ . '/tmp/cache')->setOutputBaseUrl('/tmp/cache')->setOutputForceRefresh(true)->setOutputLifeTime(0)->setOutputStrategy('manual')->setCacheDb(CombineFilesCacheDB::openFile(__DIR__ . '/tmp/cache/grunt.db'))->setScssImportDirs(array(__DIR__ . '/tmp/scss/grunt_import', __DIR__ . '/tmp/scss/grunt', __DIR__))->setScssVariables(array('path-background' => '"/images/bg.png"', 'foo' => 'red'));
         $url = new UrlManager();
         $res->setCombineObject($combine);
         $res->setUrlManager($url);
     });
     $res->add(new StyleSheetResource('style', array('/tmp/scss/style.scss,grunt'), array('combine' => true)), 'grunt_scss');
     $this->assertNotEmpty($res->render('html'));
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $output = preg_match('/^<!DOCTYPE\\s.*>$/', trim($this->doctype->render())) ? trim($this->doctype->render()) . PHP_EOL : '<!DOCTYPE html>' . PHP_EOL;
     preg_match('/<html.*?>/', $this->html->render(), $result);
     $output .= isset($result[0]) ? $result[0] . PHP_EOL : '<html>' . PHP_EOL;
     $output .= substr($this->head->render(), 0, -7);
     $favicon = $this->favicon->render();
     if (!empty($favicon)) {
         $output .= $favicon . PHP_EOL;
     }
     if ($this->styleSheet->length()) {
         $output .= $this->styleSheet->render('html') . PHP_EOL;
     }
     if ($this->javaScript->length()) {
         $tmp = call_user_func($this->scriptOutput, $this->javaScript, $this->translations);
         if (!empty($tmp)) {
             $output .= $tmp . PHP_EOL;
         }
     }
     if (!$this->script->isEmpty()) {
         $output .= '<script type="text/javascript">' . $this->script->render() . '</script>' . PHP_EOL;
     }
     $output .= $this->customHeadCode;
     $output .= '</head>' . PHP_EOL;
     $bodyEndPos = strrpos($this->body, "</body>");
     if ($bodyEndPos !== false) {
         $output .= substr($this->body, 0, $bodyEndPos);
         $output .= $this->customBottomCode . '</body>';
     } else {
         $output .= $this->body;
     }
     $output .= '</html>';
     return $output;
 }