comos / tage Goto Github PK
View Code? Open in Web Editor NEWTage, the PHP template engine. Developing...
License: GNU General Public License v3.0
Tage, the PHP template engine. Developing...
License: GNU General Public License v3.0
{{t ...}} t tag
{{t($a)}} invoking t function
It's not a high priority feature yet, for now.
?>
I've to decide how to load compiled script now.
Like this
{{foreach from=$list item='it' key='i'}}
{{$i}},{{$it}}
{{endforeach}}
After Lex,the tokens will like that:foreachTag
,newLineText
,print $i
,print $it
,newLineText
,endforeachTag
.
So the output(with list=[1,3]) should be:
newLine
0,1
newLine
1,3
newLine
That may not be expected.
$a ?? $b
!empty($a)?$a:$b
{{set x!=$a}}
,indicates x must not be nullif($x === null){
throw new NotNullableException();
}
{{set capture}}
<div></div>
{{endset}}
{{$capture}}
Include tag will compile to $this->__c->t($path)
I notice the t method can not auto merge parent renderVars.
We need to do something fix it.
Let's begin with the length
filter
How is this compiled code like?
{{$arr|length}}
赶脚是Compiler的一部分。。。
实现Lexer及TokenStream并能够跑通LexTest的测试。
I see the t include path was simply get by 'tplDir+id'.
I think we should protect id inject (which may try to access out of tplDir).
I just added some scenarios to LexTest.
I found that Lex doesn't support PHP short tag yet.
So there's a failed assertion.
By the way, the Lex's demonstration is pretty cool!
$foo
$foo.bar
$foo.bar()
字符串:'string', "string"
布尔值:true, false
空: null
数字
逻辑运算符:&&,||,!
数学运算符:+,-,,/,*(幂乘),//(整除)
字符串连接运算符: ~
range运算符: .. (如1..9 或 'a'..'z')
in 操作符: 如 $item in $items
数组:此处所说的数组是php中得通用array概念。(既是map也是数组)。如 [$a,$b,$c] 、 [3:$a,'mykey':$b,]
完成表达式解析器和表达式编译,能够通过MilestoneTest。
exceptions: Lex, Parse, Compile(After...),Runtime...
{{a+b}}
转换到etag_add(a,b)
而不是((a)+(b))
。好处是可以直接实现ab为字符串时的连接行为,无需增加新的字符串concat符。(在其它模板引擎中使用~来做字符串连接)。覆盖的问题会增加函数开销,导致解释结果的性能下降。下面是参考其它模板引擎的一些比较有趣的feature,看看是否有必要在后续考虑引入:
body
p
|
This is a test of the text block.
结果将是
<body><p>This is a test of the text block.</p></body>
类似Handlebars可以这样使用.
{{#list people}}{{firstName}} {{lastName}}{{/list}}
等同于{{people.firstName}} {{people.lastName}}
在laravel中可以对View绑定数据提供者,以此实现MVC。还可以让视图之间做数据传递(可以解决之前专题组件的联动更新问题?)。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.