diff --git a/README.md b/README.md index 3d17ca5..6849413 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,14 @@ My develop tags: - java ``` -### More usage +## More usage -**config template** +The syntax is the same as that of the PHP native template, and the special syntax is added just to make it easier to use. + +-`EasyTemplate` enables output filtering by default, which can be used to render view templates +-`TextTemplate` turns off output filtering and is mainly used for text processing, code generation, etc. + +### Config template ```php use PhpPkg\EasyTpl\EasyTemplate; @@ -96,7 +101,7 @@ $t->addFilters([]); $t->addDirective($name, $handler); ``` -**echo variable** +### Echo variable The following statements are the same, can be used to print out variable values @@ -119,7 +124,7 @@ More: - Set to disable output filtering `$t->disableEchoFilter()` - Disable output filtering in the template `{{ $name | raw }}` -**chained access array** +### Chained access array Can use `.` to quick access array value. @@ -137,7 +142,7 @@ First value is: {{ $arr.0 }} // val0 'subKey' value is: {{ $arr.subKey }} // val1 ``` -**if blocks** +### If blocks only `if`: @@ -173,7 +178,7 @@ age is {{ $age }}, and {{ endif }} ``` -**for/foreach blocks** +### For/Foreach blocks `foreach`: @@ -197,7 +202,7 @@ tags: {{ endforeach }} ``` -**add comments** +### Add comments ```php {{# comments ... #}}{{ $name }} // inhere diff --git a/README.zh-CN.md b/README.zh-CN.md index 2844750..90448e6 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -71,12 +71,14 @@ My develop tags: - java ``` -### 更多使用 +## 更多使用说明 + +语法跟PHP原生模板一样的,加入的特殊语法使用只是为了使用更加方便。 - `EasyTemplate` 默认开启输出过滤,可用于渲染视图模板 - `TextTemplate` 则是关闭了输出过滤,主要用于文本处理,代码生成等 -**配置设置** +### 配置设置 ```php use PhpPkg\EasyTpl\EasyTemplate; @@ -99,7 +101,7 @@ $t->addFilters([]); $t->addDirective($name, $handler); ``` -**输出变量值** +### 输出变量值 下面的语句一样,都可以用于打印输出变量值 @@ -121,7 +123,7 @@ $t->addDirective($name, $handler); - 设置禁用输出过滤 `$t->disableEchoFilter()` - 模板中禁用输出过滤 `{{ $name | raw }}` -**快速访问数组值** +### 快速访问数组值 可以使用`.` 来快速访问数组值。 @@ -139,7 +141,7 @@ first value is: {{ $arr.0 }} // val0 'subKey' value is: {{ $arr.subKey }} // val1 ``` -**if 语句块** +### If 语句块 `if` 语句: @@ -175,7 +177,7 @@ age is {{ $age }}, and {{ endif }} ``` -**for/foreach 语句块** +### For/Foreach 语句块 `foreach`: @@ -199,7 +201,7 @@ tags: {{ endforeach }} ``` -**模板中添加注释** +### 模板中添加注释 以 `{{#` 和 `#}}` 包裹的内容将会当做注释忽略