diff --git a/README.md b/README.md new file mode 100644 index 0000000..771361d --- /dev/null +++ b/README.md @@ -0,0 +1,124 @@ +

+ +

+

+ It will be different if you stand behind. +

+ +  + +# Avane [![GitHub release](https://img.shields.io/github/release/TeaMeow/Avane.svg?maxAge=2592000)]() + +亞凡芽是基於 PHP 的一套模板引擎,其功能支援隨機 CSS 樣式名稱, + +同時整合 JS 檔案。 + +  + +# 特色 + +1. 支援 PJAX(換網頁不重整) + +2. 減少撰寫 PHP 程式的次數。 + +3. 支援多個模板。 + +4. 支援整合 JS 和 CSS 檔案。 + +5. 支援自動編譯 Coffee、Sass。 + +6. 採用類似 Jade 的標籤,但你仍可以使用 HTML 撰寫。 + +  + +# 建置狀況 + +| 服務 | 標籤 | +| ------------- |:-------------| +| Travis CI | [![Build Status](https://travis-ci.org/TeaMeow/Avane.svg?branch=master)](https://travis-ci.org/TeaMeow/Avane) | +| Caris Events | [![Build Status](http://drone.caris.events/api/badges/TeaMeow/Avane/status.svg)](http://drone.caris.events/TeaMeow/Avane) | + +  + +# 教學 + +我們將教學從 README.md 中切割出來了, + +**你可以[在 Gitbook 上閱讀詳細的亞凡芽教學](https://yamiodymel.gitbooks.io/avane/content/)**, + +甚至是下載成 PDF 檔在任何時候都可以觀看。 + +  + +# 範例 + +你需要先初始化亞凡芽,並且傳入一個模板資料夾的路徑。 + +```php +$avane = new Avane\Main('default'); +``` + +  + +然後撰寫模板。 + +```php +div + 嗨,我是 #{$name}! +``` + +好了,然後我們把它存入 `default/tpls/homepage.jade`。 + +  + +接下來假設我們有個 `index.jade`,而這是他的內容。 + +```php +$avane = new Avane\Main('default'); + +$avane->render('homepage', ['name' => '小安']); +``` + +  + +接下來透過你的瀏覽器檢視 `index.php`,會得到下列結果。 + +```html +
嗨,我是 小安!
+``` + +  + +# 可參考文件 + +這裡是幾個可能會啟發你的創意,或者是更有利於你使用亞凡芽的連結。 + +[Writing a simple lexer in PHP](http://nitschinger.at/Writing-a-simple-lexer-in-PHP/) + +[超简单实用的php 模板引擎](http://www.cnphp.info/simple-php-template-engine.html) + +[自制php模板引擎第二版](http://www.cnphp.info/simple-php-template-engine-version-2.html) + +[Latte: amazing template engine for PHP](https://latte.nette.org/) + +[Roll Your Own Templating System in PHP](http://code.tutsplus.com/tutorials/roll-your-own-templating-system-in-php--net-16596) + +[Creating a Simple Template Engine with OO PHP.](http://ianburris.com/tutorials/oophp-template-engine/) + +[Simple PHP Template Engine](http://chadminick.com/articles/simple-php-template-engine.html#sthash.miLYug6M.dpbs) + +[Creating your own template engine in JavaScript: part 1](http://www.angrycoding.com/2012/03/creating-your-own-template-engine-in.html) + +[Nunjucks](https://mozilla.github.io/nunjucks/cn/templating.html) + +[How to Use PHP instead of Twig for Templates](http://symfony.com/doc/current/cookbook/templating/PHP.html) + +[Dust PHP](http://cretz.github.io/dust-php/) + +[TWIG](http://twig.sensiolabs.org/doc/tags/for.html) + +[Getting Started With PHP Templating](https://www.smashingmagazine.com/2011/10/getting-started-with-php-templating/) + +[Templating Engines in PHP](http://fabien.potencier.org/templating-engines-in-php.html) + +[Talesoft/tale-jade](https://github.com/Talesoft/tale-jade) diff --git a/dd.html b/dd.html deleted file mode 100644 index 00c18f1..0000000 --- a/dd.html +++ /dev/null @@ -1 +0,0 @@ -sdfsdfsdfsdfsdfff \ No newline at end of file diff --git a/php.ini b/php.ini deleted file mode 100644 index 737ed64..0000000 --- a/php.ini +++ /dev/null @@ -1 +0,0 @@ -extension=yaml.so \ No newline at end of file diff --git a/src/main.php b/src/main.php index 11c2255..6289add 100644 --- a/src/main.php +++ b/src/main.php @@ -51,7 +51,7 @@ public function setSetting($name, $value) case 'enableCoffee' : $this->enableCoffee = $value; break; case 'enableSass' : $this->enableSass = $value; break; case 'enableSassc' : $this->enableSassc = $value; break; - case 'sasscPath' : $this->sasscPath = $value; break; + case 'sassc' : $this->sasscPath = $value; break; case 'coffeeExtension': $this->coffeeExtension = $value; break; case 'sassExtension' : $this->sassExtension = $value; break; case 'pjaxHeader' : $this->pjaxHeader = $value; break; diff --git a/test/cache/views/home/ubuntu/workspace/test/default/tpls/test.phtml b/test/cache/views/home/ubuntu/workspace/test/default/tpls/test.phtml index 1fa74bc..b105d78 100644 --- a/test/cache/views/home/ubuntu/workspace/test/default/tpls/test.phtml +++ b/test/cache/views/home/ubuntu/workspace/test/default/tpls/test.phtml @@ -1 +1 @@ - null, 'icon' => null, 'label' => null];extract(array_replace($__scope, array_replace($__defaults, $__arguments)));?>>> 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['link' => 'photo', 'icon' => 'icon--picture', 'label' => 'A'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?> 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['link' => 'photo', 'icon' => 'icon--circles', 'label' => 'B'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?> 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['link' => 'photo', 'icon' => 'icon--music', 'label' => null, 0 => 'C'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?> 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['link' => 'photo', 'icon' => 'icon--draw', 'label' => null, 0 => 'D'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?> 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['link' => 'photo', 'icon' => 'icon--dna', 'label' => null, 0 => 'E'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?> 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['link' => 'photo', 'icon' => 'icon--gamepad', 'label' => 'F'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?> \ No newline at end of file +這是 HTML'?>

>>

這會是被轉義的字串:

這會是 HTML: \ No newline at end of file diff --git a/test/default/tpls/test.jade b/test/default/tpls/test.jade index b48821d..a8a92a6 100644 --- a/test/default/tpls/test.jade +++ b/test/default/tpls/test.jade @@ -1,11 +1,16 @@ -mixin item(link, icon, label) - a.item(href=$link) - span.icon(class=$icon) - $label - -+item('photo', 'icon--picture', 'A') -+item('photo', 'icon--circles', 'B') -+item('photo', 'icon--music' , 'C') -+item('photo', 'icon--draw' , 'D') -+item('photo', 'icon--dna' , 'E') -+item('photo', 'icon--gamepad', 'F') \ No newline at end of file + + +$maybeHtml= '這是一串文字而且 這是 HTML' + +p= $maybeHtml +p!= $maybeHtml + + +a(title=$maybeHtml) +a(title!=$maybeHtml) + + +p +| 這會是被轉義的字串: #{$maybeHtml} +p +| 這會是 HTML: !{$maybeHtml} \ No newline at end of file diff --git a/test/index.php b/test/index.php index d380982..edb8d77 100644 --- a/test/index.php +++ b/test/index.php @@ -2,7 +2,5 @@ include '../src/autoload.php'; $Avane = new Avane\Main(__DIR__ . '/default'); -$Avane->header('Ello', ['title' => 'dsfsdfsdfsd']) - ->render('Ello', ['items' => range(0, 1000)]) - ->footer('Ello'); +$Avane->render('Ello', ['items' => range(0, 1000)]); ?> \ No newline at end of file