Fork me on GitHub

Application - Template

#Template

#Overview

Template allows you to create the PHP code via Template Engine. Template engines work great. It can make you collaborate with designer, publisher etc.

CafeLatte(CL) Framework involves a template engine to convert HTML to PHP,

Update a Config File

in order to use template library , add a yellow color line on configure file


{
  "server_name": "TEST SERVER",
  "server_type": "develop",
  "project": {
    "name": "hello world project",
    "path": "/home/projects/my_project/",
    "version": "0.1.1",
    "url": "http://localhost",
    "security_level": "normal"
  },
  "log": {
    "level": "debug",
    "path": "/home/projects/my_project/logs/"
  },
  "template": {
    "input": "/home/projects/my_project/html/",
    "output": "/home/projects/my_project/php/",
    "user": "root",
    "group": "root"
  },
  "upload": {
    "path": "/home/projects/upload_folder_full_path/"
  },
  "config": {
    "key1": "value1",
    "key2": "value2",
    "key3": "value3",
    "key4": "value4"
  }
}

root@SERVER:# ./cafelatte template update

you can generate php code using cafelatte command below.in order to convert(generate) from html(input path) to php(output path)


 This file is part of Cafelatte framework.
 This binary helps you to convert your HTML code into PHP output statements.

 @@@@@   @   @@@@@ @@@@@ @       @   @@@@@ @@@@@ @@@@@
 @      @ @  @     @     @      @ @    @     @   @
 @     @@@@@ @@@@  @@@@@ @     @@@@@   @     @   @@@@@
 @     @   @ @     @     @     @   @   @     @   @
 @@@@@ @   @ @     @@@@@ @@@@@ @   @   @     @   @@@@@

 Cafelatte  version 1.0.0 2017-10-17

 Compile... => /home/projects/my_project/www/php//aaa.html                                      -------------------------  OK
 Compile... => /home/projects/my_project/www/php//bbb.html                                      -------------------------  OK
 Compile... => /home/projects/my_project/www/php//ccc.html                                      -------------------------  OK
 Compile... => /home/projects/my_project/www/php//test.html                                     -------------------------  OK

#How To Use

#`Common` Code


<html>
<head>
    <title>{{title}}</title>
</head>
<body>
{{body}}
</body>
</html>
            

#`IF` Code


<html>
<head>
    <title>IF Example </title>
</head>
<body>

    {{?body}}
        body is not null11
    {{:}}
        body is null
    {{/}}

</body>
</html>
            

#`Loop` Code


<html>
<head>
    <title>Loop Example </title>
</head>
<body>

    {{@ list}}
    <tr>
        <td>{.id}</td>
        <td>{.depthCode1}</td>
        <td>{.title}</a></td>
        <td>{.readCnt}</td>
        <td>{.createdAt}</td>
    </tr>
    {{:}}
    <tr>
        <td colspan='5'>No Data.</td>
    </tr>
    {{/}}
    
</body>
</html>
            

#Tutorial

To get more information, move to tutorial page, Click `Here`