It is considered that you have already read this two pages:
{{macro}} tags are stored in files with .tag.php suffix in file name. Tags files can be found in limb/macro/src/tags/ folder and also in src/macro folders of Limb3 packages and Limb-based applications.
In the head of every tag file there is a section for tag annotations. Here is annotation section of {{apply}} tag for example:
<?php /** * @tag apply * @req_attributes template */ class lmbMacroApplyTag extends lmbMacroTag { [...] } ?>
The complete list of possible tag annotations is the following:
You need to define the following attributes when you use lmbMacroRuntimeWidgetTag as parent tag:
These two attributes can also be defined in preParse(lmbMacroCompiler $compiler), see {{input}} tag in limb/macro/src/tags/form/input.tag.php
lmbMacroRuntimeWidgetTag uses lmbMacroCodeWriter :: writeToInit($php_code) method for writing initialization PHP code. lmbMacroRuntimeWidgetTag writes a PHP code that created an object of $widget_class_name class. You can access widget object variable using lmbMacroRuntimeWidgetTag :: getRuntimeVar() method (we already mentioned about getRuntimeVar() as "{{macro}} compiler" page).
lmbMacroRuntimeWidgetHtmlTag requires $html_tag class attribute to be redeclared.
$widget_class_name class attribute should point at a class that extends lmbMacroHtmlTagWidget for correct work of lmbMacroRuntimeWidgetHtmlTag.
The example of lmbMacroRuntimeWidgetHtmlTag child classes are {{form}} tag class and lmbMacroFormElementTag (see below).
If you create a regular tag you will probably inherit from lmbMacroTag or lmbMacroRuntimeWidgetTag. In such cases you'd better to override the following methods:
Don't forget to call parent _generateContent($code_writer) otherwise child nodes will not have a change to generate their contents.
If you create a tag with html-analog you will probably inherit your tag from lmbMacroRuntimeWidgetHtmlTag or lmbMacroFormElementTag and override the following methods:
lmbMacroNode :: preParse(lmbMacroCompiler $compiler) usually used for preliminary analysis of tags attributes, enclosing parent tags, etc. This method is called before generation process is started. See examples tags classes such as {{input}}, {{include}}, etc.
Обсуждение