{"id":23503505,"url":"https://github.com/realyuniquename/hhp","last_synced_at":"2026-01-24T04:06:12.223Z","repository":{"id":21323155,"uuid":"24639814","full_name":"RealyUniqueName/HHP","owner":"RealyUniqueName","description":"PHP-like templating system for Haxe","archived":false,"fork":false,"pushed_at":"2020-11-03T14:55:24.000Z","size":33,"stargazers_count":26,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-20T03:47:58.905Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Haxe","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RealyUniqueName.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-30T13:47:01.000Z","updated_at":"2024-10-26T10:59:13.000Z","dependencies_parsed_at":"2022-08-09T22:31:13.017Z","dependency_job_id":null,"html_url":"https://github.com/RealyUniqueName/HHP","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealyUniqueName%2FHHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealyUniqueName%2FHHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealyUniqueName%2FHHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealyUniqueName%2FHHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RealyUniqueName","download_url":"https://codeload.github.com/RealyUniqueName/HHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252531882,"owners_count":21763293,"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":[],"created_at":"2024-12-25T08:30:01.444Z","updated_at":"2026-01-24T04:06:12.197Z","avatar_url":"https://github.com/RealyUniqueName.png","language":"Haxe","funding_links":[],"categories":[],"sub_categories":[],"readme":"HHP\n===\nHHP is a type-safe templating system for Haxe greatly inspired by PHP programming language templating possibilities.\nHHP stands for `Haxe Hypertext Preprocessor`.\n\nIn PHP you can use plain PHP code inside of a template. This feature gives you unlimited control of template logic.\nThanks to macros we can do the same thing with Haxe, but with additional error detection at compile time!\n\nFeatures:\n---------------\n* Use any valid Haxe code inside templates.\n* Compiler's code completion for variables used in template.\n* Compile-time template parsing, which means you will get compiler notifications if:\n    * If you try to pass to template a variable which is not used in template.\n    * If you're passing a value of wrong type to a template variable.\n* Include templates in templates.\n\nRules:\n---------------\n1. In a template use tags `\u003c?hhp ... ?\u003e` to inline Haxe code. Use `this.echo(haxe_expression)` in inlined code to add `haxe_expression` value to output buffer.\n1. Use `\u003c?=haxe_expression?\u003e` to add value of `haxe_expression` to output buffer.\n1. Use `\u003c?hhp this.render('another/template.html', ...); ?\u003e` to include another template (see [hhp.Template.render()](https://github.com/RealyUniqueName/HHP/blob/master/src/hhp/Template.hx#L82) method description)\n\nBase templates path\n---------------\nIf you have all your templates in for example `path/to/my/views/templates/` you can set this path\nas base path for all templates using compiler flag:\n```\n--macro hhp.Hhp.basePath('path/to/my/views/templates/')\n```\nAnd omit this common path part in templates.\n\nExamples:\n---------------\nLet's say we have template like this:\n```html\n\u003c!-- templates/test.html --\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003e\u003c?=this.title?\u003e\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003cul\u003e\n            \u003c?hhp\n                for (i in 0...this.listSize) {\n                    this.echo('\u003cli\u003eItem #${i + 1}\u003c/li\u003e');\n                }\n            ?\u003e\n        \u003c/ul\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\nNotice: inside of a template you must use `this` to access template variables and methods\n\n*Simple way:*\n\n```Haxe\nvar content : String = hhp.Hhp.render('templates/test.html', {\n    title : 'Hello, HHP!',\n    listSize : 2\n});\n\ntrace(content);\n```\n\n*Advanced way*\n```Haxe\n//MyTemplate.hx\n@:hhp('templates/test.html')\nclass MyTemplate extends hhp.Template {\n    /**\n    * Add template variable declaration if you want to constraint allowed type or\n    *   set default value for this variable.\n    * If variable used in template is not declared in a class, it will be Dynamic.\n    */\n    public var listSize : Int = 5;\n\n\n    /**\n    * You can also add any additional methods and use them in a template.\n    */\n}\n\n\n//Main.hx\nclass Main {\n    static public function main () {\n        var tpl = new MyTemplate();\n        tpl.listSize = 10; //integer variable\n        tpl.| //get code completion with variables: title, listSize\n\n        var content : String = tpl.execute();\n        trace(content);\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealyuniquename%2Fhhp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealyuniquename%2Fhhp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealyuniquename%2Fhhp/lists"}