@@ -196,7 +196,7 @@ Loop over each item in a sequence. The following example shows how to traverse a
196196 {% endfor %}
197197 </ul>
198198
199- for-loops can also be nested :
199+ for循环嵌套 :
200200
201201.. code-block :: html+jinja
202202
@@ -237,9 +237,9 @@ The else clause is also supported:
237237 {% endfor %}
238238 </ul>
239239
240- Assignments
240+ 变量赋值
241241-----------
242- Variables may be changed in a template using the instruction "set":
242+ 在模板文件中,可以使用 "set" 设置或改变变量的值:
243243
244244.. code-block :: html+jinja
245245
@@ -248,7 +248,7 @@ Variables may be changed in a template using the instruction "set":
248248
249249Expressions
250250-----------
251- Volt provides a basic set of expression support, including literals and common operators:
251+ Volt对表达式提供了一组基本的支持,包括字符串以及常用的操作:
252252
253253+----------------------+------------------------------------------------------------------------------+
254254| Filter | Description |
@@ -268,7 +268,9 @@ Volt provides a basic set of expression support, including literals and common o
268268
269269Arrays
270270^^^^^^
271- Whether you're using PHP 5.3 or 5.4, you can create arrays by enclosing a list of values in square brackets:
271+ 无论你使用PHP 5.3 或 5.4,你都可以用 "[ ]" 括起来的形式来创建数组:
272+
273+ 译者注:如果在PHP文件中想用这种方式创建数组,PHP最低版本应该为PHP 5.4
272274
273275.. code-block :: html+jinja
274276
@@ -284,9 +286,9 @@ Whether you're using PHP 5.3 or 5.4, you can create arrays by enclosing a list o
284286 {# Hash-style array #}
285287 {{ ['first': 1, 'second': 4/2, 'third': '3'] }}
286288
287- Math
288- ^^^^
289- You may make calculations in templates using the following operators:
289+ 数学计算( Math)
290+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
291+ 你可以在模板文件中直接使用以下操作符进行计算:
290292
291293+----------------------+------------------------------------------------------------------------------+
292294| Operator | Description |
@@ -302,9 +304,9 @@ You may make calculations in templates using the following operators:
302304| \% | Calculate the remainder of an integer division {{ 10%3 }} returns 1 |
303305+----------------------+------------------------------------------------------------------------------+
304306
305- Comparisions
306- ^^^^^^^^^^^^
307- The following comparision operators are available:
307+ 比较运算符( Comparisions)
308+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
309+ 下面是在模板中可用的比较运算符:
308310
309311+----------------------+------------------------------------------------------------------------------+
310312| Operator | Description |
@@ -328,8 +330,8 @@ The following comparision operators are available:
328330| !== | Check whether both operands aren't identical |
329331+----------------------+------------------------------------------------------------------------------+
330332
331- Logic
332- ^^^^^
333+ 逻辑运算符( Logic)
334+ ^^^^^^^^^^^^^^^^^
333335Logic operators are useful in the "if" expression evaluation to combine multiple tests:
334336
335337+----------------------+------------------------------------------------------------------------------+
@@ -344,8 +346,8 @@ Logic operators are useful in the "if" expression evaluation to combine multiple
344346| ( expr ) | Parenthesis groups expressions |
345347+----------------------+------------------------------------------------------------------------------+
346348
347- Other Operators
348- ^^^^^^^^^^^^^^^
349+ 其他操作符( Other Operators)
350+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
349351Additional operators seen the following operators are available:
350352
351353+----------------------+----------------------------------------------------------------------------------------------+
@@ -376,7 +378,7 @@ The following example shows how to use operators:
376378
377379Using Tag Helpers
378380-----------------
379- Volt is highly integrated with :doc: `Phalcon\\ Tag <tags >`, so it's easy to use the helpers provided by that component in a Volt template:
381+ Volt 高度集成 :doc: `Phalcon\\ Tag <tags >`,因此你可以在Volt模板中方便的使用它们:
380382
381383.. code-block :: html+jinja
382384
@@ -394,7 +396,7 @@ Volt is highly integrated with :doc:`Phalcon\\Tag <tags>`, so it's easy to use t
394396
395397 </form>
396398
397- The following PHP is generated:
399+ 下面是生成的PHP代码:
398400
399401.. code-block :: html+php
400402
@@ -412,7 +414,7 @@ The following PHP is generated:
412414
413415 </form>
414416
415- To call a Phalcon\T ag helper, you only need to call an uncamelized version of the method:
417+ 要想在Volt模板中调用 Phalcon\T ag 助手,你只需要使用它们在Volt中对应的缩写版本即可:
416418
417419+------------------------------------+-----------------------+
418420| Method | Volt function |
@@ -454,20 +456,19 @@ To call a Phalcon\Tag helper, you only need to call an uncamelized version of th
454456| Phalcon\\ Tag::friendlyTitle | friendly_title |
455457+------------------------------------+-----------------------+
456458
457- View Integration
458- ----------------
459- Also, Volt is integrated with :doc: `Phalcon\\ Mvc\\ View <views >`, you can play with the view hierarchy and include partials as well:
459+ 视图集成( View Integration)
460+ -------------------------------
461+ Volt 模板集成了 :doc: `Phalcon\\ Mvc\\ View <views >`, 你的模板层次结构和默认的层次结构一样,你可以这样使用 partials :
460462
461463.. code-block :: html+jinja
462464
463465 {{ content() }}
464466
465467 {{ partial("partials/footer.volt") }}
466468
467- Template Inheritance
468- --------------------
469- With template inheritance you can create base templates that can be extended by others templates allowing to reuse code. A base template
470- define *blocks * than can be overriden by a child template. Let's pretend that we have the following base template:
469+ 模板继承(Template Inheritance)
470+ -------------------------------------------
471+ 模板继承:你可以创建一个基础模板,其他模板继承自这个基础模板,可提高模板文件的复用性。基础模板使用 *blocks * 定义一个块,这个块可以是可以被子模板覆盖的。现在让我们假设,我们有以下的基础模板:
471472
472473.. code-block :: html+jinja
473474
@@ -488,7 +489,7 @@ define *blocks* than can be overriden by a child template. Let's pretend that we
488489 </body>
489490 </html>
490491
491- From other template we could extend the base template replacing the blocks :
492+ 其他的模板可以继承自这个基础模板,同时替换掉基础模板中的 block :
492493
493494.. code-block :: jinja
494495
@@ -503,7 +504,7 @@ From other template we could extend the base template replacing the blocks:
503504 <p class="important">Welcome on my awesome homepage.</p>
504505 {% endblock %}
505506
506- Not all blocks must be replaced at a child template, only those which are needed. The final output produced will be the following:
507+ 并非所有的 block 都需要在子模板中进行替换(意思是,你可以替换需要的那一部分)。上面的示例最终输出结果如下:
507508
508509.. code-block :: html
509510
@@ -524,17 +525,15 @@ Not all blocks must be replaced at a child template, only those which are needed
524525 </body >
525526 </html >
526527
527- As partials, the path set to "extends" is a relative path under the current directory for views (i.e app/views/ ).
528+ 作为一个片断, "extends" 后跟的路径是一个相对于视图存放目录的相对路径(即 app/views).
528529
529530.. highlights ::
530531
531- By default, and for performance reasons, Volt only checks for changes in the children templates,
532- so it is recommended initialize Volt with the option 'compileAlways' => true. Thus, the templates
533- are compiled always taking into account changes in the parent templates.
532+ 默认情况下,出于对性能的考虑,Volt只检查子模板是否有修改。因为建议在开发阶段初始时使用 'compileAlways' => true。这样的话,模板始终检查父模板是否有修改。
534533
535534Setting up the Volt Engine
536535--------------------------
537- Volt can be configured to alter its default behavior, the following example explain how to do that:
536+ Volt是可以通过配置改变默认的行为的,下面的例子说明如何做到这一点:
538537
539538.. code-block :: php
540539
@@ -567,7 +566,7 @@ Volt can be configured to alter its default behavior, the following example expl
567566 return $view;
568567 });
569568
570- If you do not want to reuse Volt as a service you can pass an anonymous function to register the engine instead of a service name:
569+ 如果你不重用 Volt,你可以不把它作为一个服务,而是在注册 view 服务的时候,用匿名函数的方式注册Volt模板引擎:
571570
572571.. code-block :: php
573572
@@ -593,8 +592,7 @@ If you do not want to reuse Volt as a service you can pass an anonymous function
593592 return $view;
594593 });
595594
596-
597- The following options are available in Volt:
595+ Volt 配置选项:
598596
599597+-------------------+--------------------------------------------------------------------------------------------------------------------------------+---------+
600598| Option | Description | Default |
@@ -610,7 +608,7 @@ The following options are available in Volt:
610608| compileAlways | Tell Volt if the templates must be compiled in each request or only when they change | false |
611609+-------------------+--------------------------------------------------------------------------------------------------------------------------------+---------+
612610
613- External Resources
611+ 相关资源
614612------------------
615613
616614* A bundle for Sublime/Textmate is available `here <https://github.com/phalcon/volt-sublime-textmate >`_
0 commit comments