TWiki::Templates
|
|||||||||
tmplP
.
Examples:
$tmpls->expandTemplate('"blah"); $tmpls->expandTemplate('context="view" then="sigh" else="humph"'); ---++ ObjectMethod *tmplP* <tt>($attrs) -> $string</tt> Return value expanded text of the template, as found from looking in the register of template definitions. The attrs can contain a template name in _DEFAULT, and / or =context=, =then= and =else= values. Recursively expands any contained TMPL:P tags. Note that it would be trivial to add template parameters to this, simply by iterating over the other parameters (other than _DEFAULT, context, then and else) and doing a s/// in the template for that parameter value. This would add considerably to the power of templates. There is already code to do this in the MacrosPlugin. ---++ ObjectMethod *readTemplate* <tt>($name,$skins,$web) -> $text</tt> Return value: expanded template text Reads a template, constructing a candidate name for the template thus 0 looks for file =$name.$skin.tmpl= (for each skin) 0 in =templates/$web= 0 in =templates=, look for 0 looks for file =$name.tmpl= 0 in =templates/$web= 0 in =templates=, look for 0 if a template is not found, tries in this order 0 parse =$name= into a web name (default to $web) and a topic name and looks for this topic 0 looks for topic =${skin}Skin${name}Template= 0 in $web (for each skin) 0 in =TWiki::cfg{SystemWebName}= (for each skin) 0 looks for topic =${name}Template= 0 in $web (for each skin) 0 in =TWiki::cfg{SystemWebName}= (for each skin) In the event that the read fails (template not found, access permissions fail) returns the empty string ''. =$skin=, =$web= and =$name= are forced to an upper-case first character when composing user topic names. If template text is found, extracts include statements and fully expands them. Also extracts template definitions and adds them to the list of loaded templates, overwriting any previous definition.
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
Microchip and others, are registered trademarks or trademarks of Microchip Technology Inc. and its subsidiaries.
Arm® and others are registered trademarks or trademarks of Arm Limited (or its affiliates). Other terms and product names may be trademarks of others.
Ideas, requests, contributions ? Connect to LinksToCommunities page.