TWiki
>
TWiki/ Web
>
TWikiTemplatesDotPm
(revision 1) (raw view)
Edit
Attach
---+ Package =TWiki::Templates= Support for the TWiki template language. %TOC% The following tokens are supported by this language: | %<nop>TMPL:P% | Instantiates a previously defined template | | %<nop>TMPL:DEF% | Opens a template definition | | %<nop>TMPL:END% | Closes a template definition | | %<nop>TMPL:INCLUDE% | Includes another file of templates | Note; the template cache does not get reset during initialisation, so the haveTemplate test will return true if a template was loaded during a previous run when used with mod_perl or speedycgi. Frustrating for the template author, but they just have to switch off the accelerators during development. This is to all intents and purposes a singleton object. It could easily be coverted into a true singleton (template manager). ---++ ClassMethod *new* <tt>($session)</tt> Constructor. Creates a new template database object. * $session - session (TWiki) object ---++ ObjectMethod *haveTemplate* <tt>($name) -> $boolean</tt> Return true if the template exists and is loaded into the cache ---++ ObjectMethod *expandTemplate* <tt>($params) -> $string</tt> Expand the template specified in the parameter string using =tmplP=. Examples: <verbatim> $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.
Edit
|
Attach
|
P
rint version
|
H
istory
:
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r1 - 01 Feb 2006 - 09:01:25 -
TWikiContributor
TWiki/
Log In
or
Register
TWiki/ Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
User Reference
ATasteOfTWiki
TextFormattingRules
TWikiVariables
FormattedSearch
QuerySearch
TWikiDocGraphics
TWikiSkinBrowser
InstalledPlugins
Admin Maintenance
Reference Manual
AdminToolsCategory
InterWikis
ManagingWebs
TWikiSiteTools
TWikiPreferences
WebPreferences
Categories
Admin Documentation
Admin Tools
Developer Doc
User Documentation
User Tools
Webs
Abacos
Acbahia
AnpedGT16
ArcoDigital
Argumento
Avsan
CalculoB
Ceb
Cetad
CetadObserva
Cibercultura
Ciberfem
CiberParque
ColoquioCiags
Coloquiofasa
ConexoesSaberes
Cpdteste
Cppd
Creche
Cridi
Da
DACN
DCE
DelzaTeste
DeniseCarla
DepHistoria
DicionarioBelasartes
Ecologia
EDC
Educandow
EduMus
EleicoesReitor2010
Encima
Enearte
Estruturas
EstruturasEng
FACED
FAT
FepFaced
GEC
GeneticaBiodiversidade
GeneticaBiodiversidade3
GeneticaBiodiversidade
Gepindi
GetecEng
Godofredofilho
GrupoAlgebra
ICI010
Informev
Ites
LabioComp
LEG
Lepeja
Letras
LivroLivreSalvador
Main
MaisUm
Mata07
Mefes
MefesCpd
MetaReciclagem
Neclif
NelsonPretto
Nuclear
Numcad
Nutricao
Observa
OrfaosdeRua
PauloCostaLima
PdI
PescandoLetras
PETFilosofia
Pgif
PGNUT
PortalPpga
PosCultura
Pospetroigeo
PPGAC
PPGE
PpggBio
Ppggenbio
Pretto
Proad
PROGESP
ProjetoLencois
Quimica
RadioFACED
RadioTeatro
RadioWeb
Riosymposium10
Ripe
Salasdoctai
Sat
Sedu
SemBio
SeminarioPibid
SimoneLucena
Sociologia
SSL
Tabuleiro
TabuleirosUfba
TCinema
TerritoriosDigitais
TWiki
Twikidea
UFBAIrece
UniversidadeNova
VizinhoEstrangeiro
XIISNHCT
Български
English
Español
日本語
Português
Copyright � by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback