美文网首页
微擎模板引擎

微擎模板引擎

作者: StevenQin | 来源:发表于2019-04-24 18:04 被阅读0次

$this->template('xxx')说明

类似smarty模板引擎

include $this->template('index')

1、如果写在模块的前台方法function doMobileIndex(){}
模板文件的目录为:/addons/xxx应用目录/template/mobile/index.html
2、如果写在模块的后台方法function doWebIndex(){}中,模板文件的目录为:/addons/应用目录/template/index.html

输出变量

  • 前台方法
    public function doMobileIndex()
    {
        //这个操作被定义用来呈现 功能封面
        global $_W, $_GPC;
        $name="Steven Qin";
        include $this->template('index');
    }
  • 模板
输出变量是:{$name}
  • 触发路由 (MVC格式)
[http://mall.raycare.net/app/index.php?i=5&c=entry&do=index&m=health_moniter](http://mall.raycare.net/app/index.php?i=5&c=entry&do=index&m=health_moniter)

循环

  • 前台方法
 $arr = ['周一','周二','周三','周四','周五'];
  • 模板文件
循环输出变量:<br/>
{loop $arr $index $row}
  {php echo $index + 1;} => {$row} <br/>
{/loop}

条件语句

https://s.w7.cc/index.php?c=wiki&do=view&id=1&list=190

{if condition}
   {elseif condition}
   {else}
{/if}

php代码

{php echo '这样就可以写php代码了';}

url

<a href="{php echo $this->createMobileUrl('xinxi');}">跳转信息</a>

生成url如下:
http://mall.raycare.net/app/index.php?i=5&c=entry&do=xinxi&m=health_moniter

调用模板

{template '模板文件名不带后缀'}

前台方法默认在addons/template/mobile下面
后台方法默认在addons/template下面

相关文章

  • 微擎模板引擎

    $this->template('xxx')说明 类似smarty模板引擎 1、如果写在模块的前台方法functi...

  • 微擎模板路由

    前端app目录渲染模板 MVC 模式http://mall.raycare.net/app/index.php?...

  • 微擎模板消息

    sendTplNotice https://s.w7.cc/index.php?c=wiki&do=view&id...

  • laravel 5 blade

    参考Blade 模板引擎。Blade是一个模板引擎(什么叫模板引擎,参考浅谈模板引擎),文件需要采用blade.p...

  • SpringBoot系列之集成jsp模板引擎

    SpringBoot系列之集成jsp模板引擎@[toc] 1、模板引擎简介 引用百度百科的模板引擎解释: 模板引擎...

  • node_模板引擎

    模板引擎 模板引擎的使用和集成,也就是视图。 什么是模板引擎模板引擎是一个页面模板根据一定得规则生成的html工具...

  • art-template模板引擎

    模板引擎 什么是模板引擎: 模板引擎(这里特指用于Web开发的模板引擎)是为了使用户界面与业务数据(内容)分离而产...

  • Lua admin后台开发 (6) 模板引擎的使用

    上一章节我们初步了解了如何使用模板引擎, 现在我们深入了解模板引擎. 什么是模板引擎 "模板引擎(这里指Web开发...

  • Ajax-02

    模板引擎 模板引擎概述 作用:使用模板引擎提供的模板语法,可以将数据和 HTML 拼接起来。官方地址: https...

  • 《PHP Learning》模板引擎

    《PHP Learning》模板引擎 模板处理使用正则处理模板替换规则保存模板编译结果 模板使用 自定义模板引擎 ...

网友评论

      本文标题:微擎模板引擎

      本文链接:https://www.haomeiwen.com/subject/wmhngqtx.html