-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bcac8c
commit 6fe0817
Showing
7 changed files
with
143 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<p align="center"> | ||
<img src="http://imgur.com/ANJiiSB.png"/> | ||
</p> | ||
<p align="center"> | ||
<i>It will be different if you stand behind.</i> | ||
</p> | ||
|
||
| ||
|
||
# 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 | ||
<div>嗨,我是 小安!</div> | ||
``` | ||
|
||
| ||
|
||
# 可參考文件 | ||
|
||
這裡是幾個可能會啟發你的創意,或者是更有利於你使用亞凡芽的連結。 | ||
|
||
[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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/cache/views/home/ubuntu/workspace/test/default/tpls/test.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php $__mixins = [];?><?php $__mixins['item'] = function(array $__arguments, array $__scope) {$__defaults = ['link' => null, 'icon' => null, 'label' => null];extract(array_replace($__scope, array_replace($__defaults, $__arguments)));?><a class="item"<?php $__value = isset($link) ? $link : false; if (!\Tale\Jade\Compiler\is_null_or_false($__value)) echo ' href='.\Tale\Jade\Compiler\build_value($__value, '"', true); unset($__value);?>><span<?php $__values = ["icon", isset($icon) ? $icon : false]; if (!\Tale\Jade\Compiler\is_array_null_or_false($__values)) echo ' class='.\Tale\Jade\Compiler\build_class_value($__values, '"', false); unset($__values);?>></span><?=htmlentities($label, \ENT_QUOTES, 'UTF-8')?></a><?php };?><?php $__ignore = array_flip([0 => '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);?><?php $__ignore = array_flip([0 => '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);?><?php $__ignore = array_flip([0 => '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);?><?php $__ignore = array_flip([0 => '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);?><?php $__ignore = array_flip([0 => '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);?><?php $__ignore = array_flip([0 => '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);?> | ||
<?php $maybeHtml = '這是一串文字而且 <a href="#">這是 <b>HTML</b></a>'?><p><?=htmlentities(isset($maybeHtml) ? $maybeHtml : '', \ENT_QUOTES, 'UTF-8')?></p><p><?=isset($maybeHtml) ? $maybeHtml : ''?></p><a<?php $__value = isset($maybeHtml) ? $maybeHtml : false; if (!\Tale\Jade\Compiler\is_null_or_false($__value)) echo ' title='.\Tale\Jade\Compiler\build_value($__value, '"', true); unset($__value);?>></a><a<?php $__value = isset($maybeHtml) ? $maybeHtml : false; if (!\Tale\Jade\Compiler\is_null_or_false($__value)) echo ' title='.\Tale\Jade\Compiler\build_value($__value, '"', false); unset($__value);?>></a><p></p>這會是被轉義的字串: <?=htmlentities(isset($maybeHtml) ? $maybeHtml : '', \ENT_QUOTES, 'UTF-8')?><p></p>這會是 HTML: <?=isset($maybeHtml) ? $maybeHtml : ''?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
|
||
|
||
$maybeHtml= '這是一串文字而且 <a href="#">這是 <b>HTML</b></a>' | ||
|
||
p= $maybeHtml | ||
p!= $maybeHtml | ||
|
||
|
||
a(title=$maybeHtml) | ||
a(title!=$maybeHtml) | ||
|
||
|
||
p | ||
| 這會是被轉義的字串: #{$maybeHtml} | ||
p | ||
| 這會是 HTML: !{$maybeHtml} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters