:------content--------------:---------------------------
| 1. tags | kalki template
| .1 <kt> | version 0.01 @ 2001.06.19
| .2 <kteof> |
| .3 <ktp> | web://kalki.poelzi.org
| | email://kalki [at] poelzi.org
| 2. functions | copyleft 2001 poelzi.org
| .1 loadTemplate($file)
| .2 setTemplate($data)
| .3 setData($name,$data)
| .4 getResult()
|
| 3. FAQ
| .1 why
| .2 todo
| .3 changelog
| .4 outro
| .5 license
.
:1.0-------------- --- -- -
| Tags
:----------------- --- -- -
All tags look like xml style, with all little irregularity.
<kt is the beginning of all tags.
the most of them have different parameters described in their description.
BUT :)
some single parameter are set befor the />
this irregularity is nice to reduce the length of a tag and let the template more readable.
:1.1-------------- --- -- -
| <kt> - merge
:----------------- --- -- -
description
merges data into the template.
usage
<kt [attributes] [paramters]/>
attributes
--------+-------+-----------+--------------------
| long | short | | description
+--------+-------+-----------+----------------------
| text | t | necessary | define the name of the data to use.
| | | | the data is set by setData(text,[your data])
| | | |
| size | s | | length of text to insert.
| | | | on size="line" or size="l" the text to
| | | | the next linebreak will printed
| | | |
| align | a | def: r | align of text if text length is smaler than size
| | | | values: (r)ight|(c)enter|(l)eft (single char or complete)
| | | |
| fill | f | def: " " | character to fill align
| | | |
| | | |
| | | |
| | | |
| | | |
| |
|
parameters
------+---------------------
| char | description
+-----+------------------------
| e | ATTENTION:
| | the parser need to know that end of a tag wich is defined by e as the last
| | parameter, but only if the tag isn't in a kteof tag.
| | this paramter need to be the last one: <kt e/>
| | all other parameters are independente from sequence
| |
| b | kt ignores breaklines in the text
| B | enable breakline stop !b
| | default kt stop the current tag if a breakline is found.
| | default: B
| |
| W | enables wordbreak. only on a [space] will be breaked
| w | disable wordbreak. break on size
| | default: W
| |
| I | only on w:
| | kt try to break no tags.
| | he can detect if you closed it, uses a xml conform single tag (<tag />),
| | or used one of the singleTags function in the class.
| i | enables don't break option !i
| | default: I
| |
| S | kt can skip all tags found in the data. and only count real visible characters
| s | count tags too. !t
| | default: S
| |
| R | trim the last spaces from line
| r | disables rtrim
| | default: r
| |
| L | trim the first spaces from line
| l | disables ltrim
| | default: l
|
|
examples
<kt t="menu" e/>
<kt text="some" s="10" a="r" fill="." imbe/>
<ktoef t="menu"> <kt t="menu" s="l" /></ktoef>
:1.2-------------- --- -- -
| <kteof> - repeat
:----------------- --- -- -
description
repeat the content to the end of text
prepare: you need to use a secure kt tag in the kteof part with the same text
or you can become a dead loop. for secure this the class contains a max couter
to break after 1000 loops.
you cannot encase kteof
usage
<kteof [attributes]> [data] </kteof>
attributes
--------+-------+-----------+--------------------
| long | short | | description
+--------+-------+-----------+----------------------
| text | t | necessary | define the data name to look for his end.
| | | | more than one can separated by ","
| | | |
| max | m | | max loops
| | | |
| |
|
examples
+---------- -
| menu
+------- -- --
<ktoef t="menu">| <kt t="menu" s="13" s/> </ktoef>
+--- ---- - -
:1.3-------------- --- -- -
| <ktp> - preferences
:----------------- --- -- -
description
set the default preferences for kt tags
usage
<kt [attributes] />
attributes
you can use all attributes from <kt>
plus (o)ptions="[options]" to define default parameters
examples
<ktp s="10" options="wi" e/>
<ktp size="10" o="bs" e/>
Please note:
s is a alias for size and overwrite the size value.
s has a higher priority than size
:2.0-------------- --- -- -
| Functions
:----------------- --- -- -
kt is a php 4 class.
include("kalki.inc");
$template = new kalkitemplate;
$template = new kalkitemplate($mytemplatedata);
automatic loads the template.
:2.1-------------- --- -- -
| loadTemplate($file)
:----------------- --- -- -
load the template from a file
$template->loadTemplate("mytemplate.kt");
return true on success.
:2.2-------------- --- -- -
| setTemplate($data)
:----------------- --- -- -
set the template as parameter
$template->loadTemplate($mytemplatevar);
return true on success.
:2.3-------------- --- -- -
| setData($name,$data)
:----------------- --- -- -
set data to a name.
$template->setData("menu",$menuvar);
return true on success.
if data is false, the data will removed from dataholder.
:2.4-------------- --- -- -
| getResult()
:----------------- --- -- -
return a string with transformed template.
:3.0-------------- --- -- -
| FAQ
:----------------- --- -- -
:3.1-------------- --- -- -
| why
:----------------- --- -- -
i love ascii. i never saw a dynamic ascii page, here is the solution.
the problem is in the detail to merge dynamic data in a exactly build <pre>
template. this template isn't finished yet. so much ideas and optimizions to do.
:3.2-------------- --- -- -
| TODO
:----------------- --- -- -
o more testing. alpha state
+ optimize regular expressions. i hope i can remove the e/> needle.
+ formString: &...; characters should be counted as one character
+ subtemplates
+ comment code
+ better documentation
+ add tools formating tools like border around text...
:3.3-------------- --- -- -
| Changelog
:----------------- --- -- -
0.02 major release - 2001.06.19
# kt becomes a stabil state
# first public release
+ kalki now detect deathloops and stop tags. maxloops is so nasty :)
but max as attribut is anyway available
x changed the most options. big letters = enable, small = disable
+ add option l and r for trim
o fixed handling of new lines
o forgot to add a escape in formString (broken links)
+ formString can now used as kalkitemplate::formString(...) without an object
+ moved var singleTags to function singleTags
+ constants for controlling formString
0.01 initial release
+ all new :)
+-------------------------------------
| o bugfix
| x change
| + added
| - removed
| #comment
:3.4-------------- --- -- -
| outro
:----------------- --- -- -
please help me to make a better kalkitemplate :)
send comments, bugfixes, suggestions to contact
:3.5-------------- --- -- -
| license
:----------------- --- -- -
this product published under the gpl license 2 or higher.