Home  >  Article  >  Backend Development  >  有没有语法上比较像angularJS的php模板引擎

有没有语法上比较像angularJS的php模板引擎

WBOY
WBOYOriginal
2016-06-06 20:10:341014browse

初学php 看了下目前最流行的smarty语法是这样的:

<code><ul>
{%foreach $list as $item%}
<li class="{%if($item=>isBoy)%}boy{%/if%}">{%$item=>name%}</li>
{%/foreach%}
</ul>
</code>

之前用angularJS开发移动应用 很喜欢angular的模板语法:

<code><ul>
<li ng-repeat="item in list" ng-class="{boy:item.isBoy}">{{item.name}}</li>
</ul>
</code>

不知道有没有类似这样的模板引擎:

<code><ul>
<li php-repeat="$list as $item" php-class="array('boy'=>$item=>isBoy)">{%$item=>name%}</li>
</ul>
</code>

回复内容:

初学php 看了下目前最流行的smarty语法是这样的:

<code><ul>
{%foreach $list as $item%}
<li class="{%if($item=>isBoy)%}boy{%/if%}">{%$item=>name%}</li>
{%/foreach%}
</ul>
</code>

之前用angularJS开发移动应用 很喜欢angular的模板语法:

<code><ul>
<li ng-repeat="item in list" ng-class="{boy:item.isBoy}">{{item.name}}</li>
</ul>
</code>

不知道有没有类似这样的模板引擎:

<code><ul>
<li php-repeat="$list as $item" php-class="array('boy'=>$item=>isBoy)">{%$item=>name%}</li>
</ul>
</code>

https://github.com/esvit/php-angular

随意搜了一下找到这个,应该有人做过了。我个人觉得还是挺好的,而且PHP也完全可以实现。

smarty的标签对是可以做修改的!

没想到居然有和我想法一样的, 之前我也找过类似angularjs的php模板引擎, 没找到, 后来就自己写了个:http://www.kancloud.cn/shuai/php-angular/127397

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn