{"id":27233671,"url":"https://github.com/contributte/platte","last_synced_at":"2025-04-10T15:02:14.978Z","repository":{"id":57038546,"uuid":"41828193","full_name":"contributte/platte","owner":"contributte","description":"Latte template engine for Phalcon","archived":false,"fork":false,"pushed_at":"2018-03-09T01:11:03.000Z","size":19,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T13:11:18.408Z","etag":null,"topics":["latte","latte-template-engine","macros","phalcon"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/contributte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-02T21:16:05.000Z","updated_at":"2025-01-01T16:43:38.000Z","dependencies_parsed_at":"2022-08-24T00:51:01.462Z","dependency_job_id":null,"html_url":"https://github.com/contributte/platte","commit_stats":null,"previous_names":["contributte/platte"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contributte%2Fplatte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contributte%2Fplatte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contributte%2Fplatte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contributte%2Fplatte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contributte","download_url":"https://codeload.github.com/contributte/platte/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248240930,"owners_count":21071040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["latte","latte-template-engine","macros","phalcon"],"created_at":"2025-04-10T15:01:46.082Z","updated_at":"2025-04-10T15:02:14.890Z","avatar_url":"https://github.com/contributte.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Platte\n\n[![Phalconist](https://phalconist.com/phalette/platte/default.svg)](https://phalconist.com/phalette/platte)\n[![Build Status](https://img.shields.io/travis/phalette/platte.svg?style=flat-square)](https://travis-ci.org/phalette/platte)\n[![Code coverage](https://img.shields.io/coveralls/phalette/platte.svg?style=flat-square)](https://coveralls.io/r/phalette/platte)\n[![Downloads this Month](https://img.shields.io/packagist/dt/phalette/platte.svg?style=flat-square)](https://packagist.org/packages/phalette/platte)\n[![Latest stable](https://img.shields.io/packagist/v/phalette/platte.svg?style=flat-square)](https://packagist.org/packages/phalette/platte)\n[![HHVM Status](https://img.shields.io/hhvm/phalette/platte.svg?style=flat-square)](http://hhvm.h4cc.de/package/phalette/platte)\n\nCombination of one of the best template engine Latte and pretty fast framework Phalcon.\n\n## Install\n\n```sh\n$ composer require phalette/platte:dev-master\n```\n\n### Dependencies\n\n* **PHP \u003e= 5.5.0**\n* [Latte \u003e= 2.3.0](https://github.com/nette/latte)\n* [Phalcon \u003e= 2.0.0](https://github.com/phalcon/cphalcon/)\n\n## Configuration\n\nRegister Platte as your next `template engine`.\n\n```php\nuse Phalette\\Platte\\Latte\\LatteFactory;\nuse Phalette\\Platte\\LatteTemplateAdapter;\n\n$di-\u003eset('view', function () {\n    $view = new View();\n    \n    $view-\u003eregisterEngines([\n        \".latte\" =\u003e function ($view, $di) {\n            $factory = new LatteFactory();\n            $factory-\u003esetTempDir(__DIR__ . '/cache');\n            return new LatteTemplateAdapter($view, $di, $factory);\n        },\n    ]);\n    return $view;\n});\n```\n\n\n## Features from Phalcon\n\nYou can access variables in templates.\n\n| Variables    |                                                                                    |\n|--------------|------------------------------------------------------------------------------------|\n| `$_view`     | [Phalcon\\Mvc\\View](https//docs.phalconphp.com/en/latest/api/Phalcon_Mvc_View.html) |\n| `$_tag`      | [Phalcon\\Tag](https//docs.phalconphp.com/en/latest/api/Phalcon_Tag.html)           |\n| `$_url`      | [Phalcon\\Mvc\\Url](https//docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Url.html)   |\n| `$_security` | [Phalcon\\Security](https//docs.phalconphp.com/en/latest/api/Phalcon_Security.html) |\n\nIn extreme cases you can access **$_di**. But I really not recommend it.\n\n### Macros\n\n| Files \u0026 contents |                            |\n|------------------|----------------------------|\n| `{content}`          | `$_view-\u003egetContent()`     |\n| `{partial}`          | `$_view-\u003egetPartial($path)`|\n\n| Links \u0026 urls     |                            |\n|------------------|----------------------------|\n| `{linkTo}`           | `$_tag-\u003elinkTo($args...)`  |\n| `{url}`              | `$_url-\u003eget($uri)`         |\n\n| Forms         |                                   |\n|---------------|-----------------------------------|\n| `{textField}`     | `$_tag-\u003etextField($args)`         |\n| `{passwordField}` | `$_tag-\u003epasswordField($args)`     |\n| `{hiddenField}`   | `$_tag-\u003ehiddenField($args)`       |\n| `{fileField}`     | `$_tag-\u003efileField($args)`         |\n| `{radioField}`    | `$_tag-\u003eradioField($args)`        |\n| `{submitButton}`  | `$_tag-\u003esubmitButton($args)`      |\n| `{selectStatic}`  | `$_tag-\u003eselectStatic($args...)`   |\n| `{select}`        | `$_tag-\u003eselect($args...)`         |\n| `{textArea}`      | `$_tag-\u003etextArea($args)`          |\n| `{form}`          | `$_tag-\u003eform($args)`              |\n| `{endForm}`       | `$_tag-\u003eendForm()`                |\n\n| Other         |                                  |\n|---------------|----------------------------------|\n| `{title}`         | `$_tag-\u003egetTitle()`              |\n| `{friendlyTitle}` | `$_tag-\u003efriendlyTitle($args...)` |\n| `{doctype}`       | `$_tag-\u003egetDocType()`            |\n\n| Assets            |                                      |\n|-------------------|--------------------------------------|\n| `{stylesheetLink}`    | `$_tag-\u003estylesheetLink($args...)`    |\n| `{css}`               | `$_tag-\u003ejavascriptInclude($args...)` |\n| `{javascriptInclude}` | `$_tag-\u003ejavascriptInclude($args...)` |\n| `{js}`                | `$_tag-\u003ejavascriptInclude($args...)` |\n| `{image}`             | `$_tag-\u003eimage($args)`                |\n\n| Security          |                                    |\n|-------------------|------------------------------------|\n| `{securityToken}`     | `$_security-\u003egetToken()`           |\n| `{securityTokenKey}`  | `$_security-\u003egetTokenKey()`        |\n\n## Features from Nette\n\nYou can use all the great features from the Latte.\n\n### Latte Template Engine\n\nSee more on [official documentation](https://doc.nette.org/en/2.3/templating).\n\nYou can use **macros** and **filters**.\n\n#### Macros \n\nClassic macros\n\n```latte\n\u003cul\u003e\n    {foreach $users as $user}\n        \u003cli\u003e{$user-\u003ename}\u003c/li\u003e\n    {/foreach}\n\u003c/ul\u003e\n```\n\nN-macros\n\n```latte\n\u003cul n:foreach=\"$users as $user\"\u003e\n    \u003cli\u003e{$user-\u003ename}\u003c/li\u003e\n\u003c/ul\u003e\n```\n\n#### Filters\n\n```latte\n{var $time =\u003e time()}\nIt's {$time|date:'d.m.Y'} at {$time|date:'H:i:s'}\n```\n\n\n### Latte Macros\n\nSee more on [official documentation](https://doc.nette.org/en/2.3/default-macros).\n\n| Variable and expression printing                                  |                                                      |\n|-------------------------------------------------------------------|------------------------------------------------------|\n| `{$variable}`                                                     | prints an escaped variable                           |\n| `{$variable|noescape}`                                            | prints a variable without escaping                   |\n| `{expression}`                                                    | prints an escaped expression                         |\n| `{expression|noescape}`                                           | prints an expression without escaping                |\n\n| Conditions                                                        |                                                      |\n|-------------------------------------------------------------------|------------------------------------------------------|\n| `{if $cond} … {elseif $cond} … {else} … {/if}`                  | if condition                                         |\n| `{ifset $var} … {elseifset $var} … {/ifset}`                     | if (isset()) condition                               |\n\n| Loops                                                             |                                                      |\n|-------------------------------------------------------------------|------------------------------------------------------|\n| `{foreach $arr as $item} … {/foreach}`                            | foreach loop                                         |\n| `{for expr; expr; expr} … {/for}`                                 | for loop                                             |\n| `{while expr} … {/while}`                                         | while loop                                           |\n| `{continueIf $cond}`                                               | conditional jump to the next iteration               |\n| `{breakIf $cond}`                                                  | conditional loop break                               |\n| `{first} … {/first}`                                              | prints if first iteration                            |\n| `{last} … {/last}`                                                | prints if last iteration                             |\n| `{sep} … {/sep}`                                                  | separator                                            |\n\n| Variables                                                         |                                                      |\n|-------------------------------------------------------------------|------------------------------------------------------|\n| `{var $foo = value}`                                              | variable creation                                    |\n| `{default $foo = value}`                                          | default value when variable isn't declared           |\n| `{capture $var} … {/capture}`                                    | captures a section to a variable                     |\n\n| Engine                                                            |                                                      |\n|-------------------------------------------------------------------|------------------------------------------------------|\n| `{include 'file.latte'}`                                          | includes a template from other file                  |\n| `{cache $key} … {/cache}`                                        | caches a template section                            |\n| `{php expression}`                                                | evaluates an expression without printing it          |\n| `{* comment text *}`                                              | a comment (removed from evaluation)                  |\n| `{syntax mode}`                                                   | switches the syntax at runtime                       |\n| `{use Class}`                                                     | loads new user-defined macros                        |\n| `{l} or {r}`                                                      | prints { and } characters, respectively              |\n| `{contentType $type}`                                             | switches the escaping mode and sends HTTP header     |\n| `{status $code}`                                                  | sets an HTTP status code                             |\n\n| HTML tag attributes                                               |                                                      |\n|-------------------------------------------------------------------|------------------------------------------------------|\n| `n:class`                                                         | smart class attribute                                |\n| `n:attr`                                                          | smart HTML attributes                                |\n| `n:ifcontent`                                                     | Omit empty HTML tag                                  |\n| `n:tag-if`                                                        | Omit HTML tag if condition is FALSE                  |\n\n| Translations                                                      |                                                      |\n|-------------------------------------------------------------------|------------------------------------------------------|\n| `{_}Text{/_}`                                                     | translates a text                                    |\n| `{_expression}`                                                   | translates an expression and prints it with escaping |\n\n| Blocks, layouts, template inheritance                             |                                                      |\n|-------------------------------------------------------------------|------------------------------------------------------|\n| `{block block}`                                                   | block definition and immediate print out             |\n| `{define block}`                                                  | block defintion for future use                       |\n| `{include block}`                                                 | inserts a block                                      |\n| `{include mytemplate.latte}`                                      | inserts a template                                   |\n| `{includeblock 'file.latte'}`                                     | loads blocks from external template                  |\n| `{layout 'file.latte'}`                                           | specifies a layout file                              |\n| `{extends 'file.latte'}`                                          | alias for {layout}                                   |\n| `{ifset #block} … {/ifset}`                                      | condition if block is defined                        |\n\n### Latte Filters\n\nSee more on [official documentation](https://doc.nette.org/en/2.3/default-filters).\n\n| String modification                           |                                                                                |\n|-----------------------------------------------|--------------------------------------------------------------------------------|\n| `truncate (length, append = '..')`            | shortens the length preserving whole words                                     |\n| `substr (offset [, length])`                  | returns part of the string                                                     |\n| `trim (charset = whitespace)`                 | strips whitespace or other characters from the beginning and end of the string |\n| `striptags`                                   | removes HTML tags                                                              |\n| `strip`                                       | removes whitespace                                                             |\n| `webalize (charlist = '...', lower = TRUE)`   | returns string in cool URL form                                                |\n| `toAscii`                                     | removes accents                                                                |\n| `indent (level = 1, char = \"\\t\"\")\"`           | indents the text from left with number of tabs                                 |\n| `replace (search, replace = '')`              | replaces all occurrences of the search string with the replacement             |\n| `replaceRE (pattern, replace = '')`           | replaces all occurrences according to regular expression                       |\n| `padLeft (length, pad = ' ')`                 | completes the string to given length from left                                 |\n| `padRight (length, pad = ' ')`                | completes the string to given length from right                                |\n| `repeat (count)`                              | repeats the string                                                             |\n| `implode (glue = '')`                         | joins an array to a string                                                     |\n| `nl2br`                                       | new lines with \u003cbr\u003e                                                            |\n\n| Letter casing                            |                                                                                |\n|------------------------------------------|--------------------------------------------------------------------------------|\n| `lower`                                  | makes a string lower case                                                      |\n| `upper`                                  | makes a string upper case                                                      |\n| `firstUpper`                             | makes the first letter upper case                                              |\n| `capitalize`                             | lower case, the first letter of each word upper case                           |\n\n| Formatting                               |                                                                                |\n|------------------------------------------|--------------------------------------------------------------------------------|\n| `date (format)`                          | formats date                                                                   |\n| `number (decimals = 0, decPoint = '.')`  | format number                                                                  |\n| `bytes (precision = 2)`                  | formats size in bytes                                                          |\n\n| Other                                    |                                                                                |\n|------------------------------------------|--------------------------------------------------------------------------------|\n| `noescape`                               | prints a variable without escaping                                             |\n| `dataStream (mimetype = detect)`         | Data URI protocol conversion                                                   |\n| `escapeurl`                              | escapes parameter in URL                                                       |\n| `length`                                 | returns length of a string                                                     |\n| `null`                                   | flushes the input, returns nothing                                             |\n\n## Features from your own\n\n### Writing macros\n\n1) Define macros\n\n```php\nuse Latte\\Compiler;\nuse Latte\\Macros\\MacroSet;\nuse Phalette\\Platte\\Latte\\MacroInstaller;\n\nfinal class MyUltraMacros extends MacroSet implements MacroInstaller\n{\n    public static function install(Compiler $compiler)\n    {\n        $me = new static($compiler);\n        \n        $me-\u003eaddMacro(...);\n    }\n}\n```\n\n2) Register to `LatteFatory`\n\n```php\n$factory = new LatteFactory();\n$factory-\u003eaddMacro(new MyUltraMacros);\n```\n\n### Writing filters\n\n1) Define filters\n\n```php\nfinal class MyUltraFilters\n{\n    public static function hi($name) \n    {\n        return \"Hi $name\";\n    }\n}\n```\n\n2) Register to `LatteFatory`\n\n```php\n$factory = new LatteFactory();\n$factory-\u003eaddFilter('sayhi', ['MyUltraFilters', 'hi']);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontributte%2Fplatte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontributte%2Fplatte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontributte%2Fplatte/lists"}