zoukankan      html  css  js  c++  java
  • thinkphp 集成 twig模版引擎

    下载地址:https://github.com/fucongcong/ThinkPHPLevel/archive/master.zip

    控制器格式为:
    <?php
    namespace HomeController;
    use ThinkController;
    class IndexController extends Controller {
        public function index(){
    
            return $this->render(T('Index/index'),array(
                'hello'=>"张三11",'sss'=>'aaa')
            );
         }
        public function add(){
              
            $data = array(
                      0 => array(
                          "id" => 1 ,
                         "name" => "张三0",
                         "age" => 20,
                         "sex" => "女"
                       ),
                      1 => array(
                          "id" => 1 ,
                         "name" => "张三1",
                         "age" => 20,
                         "sex" => "女"
                       ),
                      2 => array(
                          "id" => 1 ,
                         "name" => "张三2",
                         "age" => 20,
                         "sex" => "女"
                       ),
            );
            $data1 = array(
                 "name" => "王五"
                );
            var_dump($data);
            return $this->render(T('Index/add'),array('data'=>$data,"data1"=>$data1));//传递多维数组
        
         }
    }
    #twig 解析

    {% extends './Public/layout.html.twig' %} {% block title%} {{group.title|default("")}} {% endblock %} {% block body %} {{ hello }} {{ data1.name }} {{ age }} {{ sex }}
    <ul> {% for user in data %} <li>{{ user.name}}</li> {% else %} <li><em>no user 12132131found</em></li> {% endfor %} </ul> {{ data1['name'] }} {% endblock %}
  • 相关阅读:
    MongoDB高级操作
    MongoDB基本操作
    Python字符串
    Git标签和别名管理
    Git分支管理
    Git远程仓库(github
    Git分布式版本管理工具基本使用方法
    CentOS7防火墙
    CentOS7新特性
    Linux系统初始流程
  • 原文地址:https://www.cnblogs.com/hgj123/p/4979863.html
Copyright © 2011-2022 走看看