{"repo":"micropackage/templates","free":true,"listed":false,"github":"https://github.com/micropackage/templates","clone":"git clone https://github.com/micropackage/templates.git","description":"Simple PHP template engine which is easy to use","language":"PHP","stars":29,"topics":["micropackage","wordpress","template-engine","composer-library","bracketspace"],"license":"GPL-3.0","category":"self-hosted-apps","readme_excerpt":"Templates 🧬 About Templates Templates micropackage is very simple WordPress template engine with multi-storage support. The templates are not parsed or cached like Blade or Twig templates. It's just good ol' file loader with variable support. 💾 Installation 🕹 Usage Let's assume your template tree looks like this: First, you need to define at least one template storage. In the above case we have two places with templates. Then you can easily render template: The template file could look like this: Accessing variables in the template file In the template file, $this points to the template instance, which means you can access all the template methods. The basic usage is: But you can also use the shorthand closure methods: Default variable values When variable is not defined, you can specify its default value: Available template methods Template class methods. Method Description Returns ----------------------------------------------- --------------------------------- ------------------------------------------------------------ Gets full path with extension (string) Gets relative path with extension (string) Gets all variables (array) Clears all variables $this Sets the variable value $this Gets the variable value (mixed\\ null) Null if variable with given name wasn't set Prints the variable value void Removes the variable $this Renders the template void Outputs the template (string) Template constructor params Parameter Type Description -------------------- ------------ -------","default_branch":null,"files":null,"tree":[],"storefront":"/r/micropackage","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/micropackage/templates/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}