PHP.MVC的模板标签系统(三)

2019-04-07 19:27:41刘景俊

    声明的变量现在可以在页面中使用了:
<!-- start_page_contents_include -->
...
<!-- Content section heading -->
<h4><@=dealHeading @> <@=saleMonth @></h4>

<center>
Clearance deals
<table class='productsTable'>
   ...
</table>
</center>

<center>
Todays specials
<table class='productsTable'>
   ...
</table>
</center>
...
<!-- end_page_contents_include -->
    这些页变量将被输出为:
<!-- Content section heading -->
<h4>Jack's Super Deals for : May 2010</h4>
...
...

表达式

    表达式标签允许我们在模板页中执行表达式.表达式的结果将被包含进模板页.以下表达式将被用来显示一个简单的字符串(salesAreaID),也可以找回框架配置类的属性:
<@ =salesAreaID @>
<@ =viewConfig.contactInfo @>
    为了使用这些表达式,我们要在之前声明过:
<@ salesAreaID = "Central District" @>
    或者在ViewResourcesConfig对象(viewConfig)的属性在view-resources结点中声明过:
<view-resources
    appTitle    = "Flash Jacks' Sleek Tab Site"
    contactInfo = "flash.jack@jackshost.com"
    ...
  </view-resources>
    当使用表达式中的对象时,我们能够写一个对象-方法(object-method)声明在标准的PHP符号或者点风格的符号:
The PhpMVC_Tags Object-Method Notation 
PHP Style  sales = data->getSales 
Dot Style  sales = data.getSales 
With Method Params  staff = data.getValueBean("STAFF") 
Retrieve Data Array  products = data->getValueBean("PRODUCTS_ARRAY") 
    在下一个单元我们将看到如何使用模板标签系统将这些结合在一起来构建页面.

相关文章 大家在看