From: Andrey Kutejko Date: Tue, 30 Jul 2013 22:13:38 +0000 (+0300) Subject: add some documentation X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=9b00d636be5db7b6147fd6f6899068f26b8e17b1;p=ipf-template.git add some documentation --- diff --git a/README.org b/README.org new file mode 100644 index 0000000..abfedc4 --- /dev/null +++ b/README.org @@ -0,0 +1,10 @@ +#+TITLE: IPF Template Engine + +* Documentation + + [[file:doc/language.org][Template Language]] + +* Run tests + + =./vendor/bin/phpunit t= + diff --git a/doc/language.org b/doc/language.org new file mode 100644 index 0000000..6ec332b --- /dev/null +++ b/doc/language.org @@ -0,0 +1,113 @@ +* IPF Template Language + + This document describes template language of IPF framework. + + Templates are placed in 'templates' directories of project or application. + + =[ ]?= -- optional code + + =[ ]*= -- code can be repeated zero or more times. + +** Tags + +*** print + Syntax: ={[modifiers]?}= + + Outputs expression. + +*** if/elseif/else + Syntax: ={if }= [ ={elseif }= ]* [ ={else}= ]? ={/if}= + +*** while + Syntax: ={while }= ={/while}= + +*** foreach + Syntax: ~{foreach as [ =>]? }~ ~{/foreach}~ + + Iterate over collection. + + Following variables are defined in a loop body: + + =foreach_counter0= -- zero based iteration counter + + =foreach_counter1= -- unit based iteration counter + + =foreach_first= -- is true on first iteration and false on the rest ones. + +*** assign + Syntax: ={assign }= + + Example: ~{assing $v += 1}~ + +*** literal + Syntax: ={literal}= ={/literal}= + + Literally output enclosed text. Mostly used to wrap inlined JavaScript. + +*** include + Syntax: ={include ""}= + + Example: ={include "pagination.html"}= + + Substitutes another template. + +*** block + Syntax: ={block }= ={/block}= + + Defines or redefines named block. + +*** superblock + Syntax: ={superblock}= + + Placeholder for content of inherited block. + +*** extends + Syntax: ={extends ""}= + + Example: ={extends "base.html"}= + + Declares current template as defived one. Top level blocks are substituted into corresponding blocks of base template. + +*** ldelim, rdelim + Syntax: ={ldelim}=, ={rdelim}= + + Output '{' and '}'. + +*** trans, plural, blocktrans + No information about these tags + +** Modifiers + + Modifier is a transformation applied to a printed value. + Some modifiers have one or more parameters. All parameters have default values and can be omitted. + + ={ [|[:]?]*}= + + Where == is a comma-separated list of parameters. + + Examples: ={$content|safe}=, ={$content|strip_tags|limit_words:10}= + +*** Predefined modifiers + + + =upper= + + =lower= + + =capitalize= + + =trim= + + + =limit_words:,= -- Limits text to specified number of words (default is 100). Text is terminted by string (default is ellipsis character). + + =limit_chars:,= -- Limits text to specified number of characters (default is 500). Text is terminted by string (default is ellipsis character). + + + =date:= -- format date. Default format is '%b %e, %Y' + + =time:= -- format date and time. Default format is 'Y-m-d H:i:s' + + + =floatformat:,= -- format float value. Default parameters are 2, '.', ','. + + + =count= -- number of elements in collection + + + =escxml= -- escape XM + + =escape= -- escape HTML + + =escurl= -- escape URL + + =strip_tags= -- remove all tags + + =nl2br= -- replaces all new line characters with '
' tags + + =unsafe=, =safe= -- outputs text unescaped + + + =debug= -- print_r + + =fulldebug= -- var_export +