MapMint Cheetah templates How To - AniketDGiri/mapmint GitHub Wiki
What I have learned during the GSOC Period:
This will be helpful for future contributors, which will help to understand the code implementation better.
Cheetah Templating System:
Cheetah3 is a free and open-source template engine and code-generation tool written in Python. Cheetah is a domain-specific language for markup generation and templating which allows for full integration with existing Python code but also offers extensions to traditional Python syntax to allow for easier text generation.
-
It allows us to implement python code, with the existing HTML, CSS, JS code.
-
Each file created using a cheetah templating system is called a template file and saved using the .tmpl extension.
-
for adding any code for python, we need to use the # symbol at the start then write the code:
Examples below: #import zoo #import datastores.directories.service as ds #import os #import mm_access
-
For creating any variable we use #set:
Examples below: #set tmpl=$conf['main']['templatesPath']+"/Distiller/form_line.html" #include $tmpl #set ftmpl=$self._CHEETAH__cheetahIncludes[$tmpl]
-
For providing the definition for a function we need to declare the function using #def function_name :
#def function name write code here #end def
-
Defined function can be called using $function_name: Note: If the function is defined using parameters, then we can call using $function_name(parm1,parm2,..)
$function_name
-
Conditional If-else statements can be written as:
#if code for the condition: Statements to be executed #end if