Skip to content
Marek Fišera edited this page Jan 29, 2022 · 23 revisions

Here is a complete example of whats possible in tag lib definition.

<?xml version="1.0" encoding="utf-8" ?>
<taglib xmlns="http://schemas.neptuo.com/xsd/is4wfw/taglib.xsd">

    <!-- PHP class namespace -->
    <namespace>is4wfw\libs</namespace>

    <!-- Maximum count of instance on a page -->
    <count>*</count>

    <!-- Purpose of a library -->
    <comment>
        Knihovna pro správu proměnných systému.
    </comment>

    <!-- Marks a library as disposable. Must declare method "dispose" which is called at the end of the request -->
    <disposable />
    
    <!-- Self closing tag -->
    <tag>
    
        <!-- A name of the tag used inside markup -->
        <name>declare</name>

        <!-- PHP function to execute -->
        <function>setValue</function>
        
        <!-- A marker for custom tag actions (no UI is generated from this tag). Use the element only when the tag is lookless. -->
        <lookless />

        <!-- A marker for making custom tag obsolete -->
        <obsolete>
            <!-- Optional description of replacement -->
        </obsolete>
        
        <!-- A list of attributes -->
        <attribute>
        
            <!-- Attribute name inside markup -->
            <name>name</name>

            <!-- Whether attribute is required or not. Use element only if the attribute is required. -->
            <required />

            <!-- Default value if attribute was not specified inside markup -->
            <default>false</default>

            <!-- A type of the attribute value. Default value must be provided to work properly. -->
            <type preferPropertyReference="true">string|number|bool|propertyReference</type>

            <!-- Whether attribute is prefix (eg. filter-*). Also direct prefix can be used (eg. filter). Use element only for prefix attributes. -->
            <prefix />

            <!-- Documentation of attribute -->
            <comment>Název proměnné, která se má nastavit.</comment>

            <!-- A marker for making custom tag obsolete -->
            <obsolete>
                <!-- Optional description of replacement -->
            </obsolete>
        </attribute>
        
        <!-- All other attributes will be assed as a special params attribute in form of associative array -->
        <anyAttribute />
        
        <!-- Documentation of the tag -->
        <comment>
            Nastaví hodnotu proměnné s názvem 'name'.
        </comment>
    </tag>

    <!-- All other tags -->
    <anyTag>
        <!-- PHP function to execute -->
        <function>anything</function>

        <!-- Documentation of the any tag -->
        <comment>
            Lorem ipsum...
        </comment>
    </anyTag>

    <!-- A full tag with a body. This body is passed as a first argument to PHP function -->
    <fulltag>
        <!-- Same as &lt;tag&gt; -->
        ...
    </fulltag>

    <!-- All other full tags -->
    <anyFulltag>
        <!-- Same as &lt;anyTag&gt; -->
        ...
    </anyFulltag>

    <!-- A custom property definition -->
    <property>

        <!-- A name of the property used inside markup -->
        <name>userId</name>

        <!-- PHP function used to set a value -->
        <setFunction>setUserId</setFunction>

        <!-- PHP function used to get a value -->
        <getFunction>getUserId</getFunction>

        <!-- A marker for making custom tag obsolete -->
        <obsolete>
            <!-- Optional description of replacement -->
        </obsolete>
        
        <!-- Documentation of the property -->
        <comment>
            Uchovává hodnotu Id aktuálního uživatele.
        </comment>
    </property>

    <!-- All other properties are mapped to function 'getProperty' -->
    <anyProperty>
        <comment>
            Uchovává hodnotu Id aktuálního uživatele.
        </comment>
    </anyProperty>
    <decorator>

        <!-- PHP function to execute -->
        <function>provideBodyById</function>

        <!-- List of attributes -->
        <attribute>
            <!-- Same as tag attribute -->
        </attribute>

        <features>
            <!-- Provides body for full tag written as selfclosing. -->
            <providesFullTagBody />

            <!-- Has access to decorated tag attributes and can modify them. -->
            <modifiesAttributes />

            <!-- Can decide whether the inner tag will execute. -->
            <conditionsExecution />
        </features>

        <!-- Documentation of the decorator -->
        <comment>Poskytuje obsah těla pro párový tag ze šablony.</comment>
    </decorator>
</taglib>
Clone this wiki locally