{"id":13636208,"url":"https://github.com/openresty/lemplate","last_synced_at":"2025-04-19T04:32:20.690Z","repository":{"id":136299893,"uuid":"87471782","full_name":"openresty/lemplate","owner":"openresty","description":"OpenResty/Lua template framework implementing Perl's TT2 templating language","archived":false,"fork":false,"pushed_at":"2019-11-05T09:25:17.000Z","size":1184,"stargazers_count":53,"open_issues_count":2,"forks_count":9,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-02-14T00:52:39.019Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","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/openresty.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-06T20:25:49.000Z","updated_at":"2022-11-12T07:22:32.000Z","dependencies_parsed_at":"2023-07-24T07:01:14.075Z","dependency_job_id":null,"html_url":"https://github.com/openresty/lemplate","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openresty%2Flemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openresty%2Flemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openresty%2Flemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openresty%2Flemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openresty","download_url":"https://codeload.github.com/openresty/lemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249606495,"owners_count":21298851,"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-08-02T00:00:58.554Z","updated_at":"2025-04-19T04:32:20.402Z","avatar_url":"https://github.com/openresty.png","language":"Perl","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Name\n\nLemplate - OpenResty/Lua template framework implementing Perl's TT2 templating language\n\nTable of Contents\n=================\n\n* [Name](#name)\n* [Status](#status)\n* [Synopsis](#synopsis)\n* [Description](#description)\n* [HowTo](#howto)\n* [Public API](#public-api)\n* [Current Support](#current-support)\n* [Community](#community)\n    * [English Mailing List](#english-mailing-list)\n    * [Chinese Mailing List](#chinese-mailing-list)\n* [Code Repository](#code-repository)\n* [Bugs and Patches](#bugs-and-patches)\n* [Credit](#credit)\n* [Author](#author)\n* [Copyright](#copyright)\n* [See Also](#see-also)\n\n# Status\n\nThis is still under early development. Check back often.\n\n# Synopsis\n\nFrom the command-line:\n\n    lemplate --compile path/to/lemplate/directory/ \u003e myapp/templates.lua\n\nFrom OpenResty Lua code:\n\n    local templates = require \"myapp.templates\"\n    ngx.print(templates.process(\"homepage.tt2\", { var1 = 32, var2 = \"foo\" }))\n\nFrom the command-line:\n\n    lemplate --compile path/to/lemplate/directory/ \u003e myapp/templates.lua\n\n# Description\n\nLemplate is a templating framework for OpenResty/Lua that is built over\nPerl's Template Toolkit (TT2).\n\nLemplate parses TT2 templates using the TT2 Perl framework, but with a twist.\nInstead of compiling the templates into Perl code, it compiles them into Lua\nthat can run on OpenResty.\n\nLemplate then provides a Lua runtime module for processing the template code.\nPresto, we have full featured Lua templating language!\n\nCombined with OpenResty, Lemplate provides a really simple and powerful way to\ndo web stuff.\n\n[Back to TOC](#table-of-contents)\n\n# HowTo\n\nLemplate comes with a command line tool call `lemplate` that you use to\nprecompile your templates into a Lua module file. For example if you have a\ntemplate directory called `templates` that contains:\n\n    $ ls templates/\n    body.tt2\n    footer.tt2\n    header.tt2\n\nYou might run this command:\n\n    $ lemplate --compile template/* \u003e myapp/templates.lua\n\nThis will compile all the templates into one Lua module file which can be loaded in your\nmain OpenResty/Lua application as the module `myapp.templates`.\n\nNow all you need to do is load the Lua module file in your OpenResty app:\n\n    local templates = require \"myapp.templates\"\n\nand do the HTML page rendering:\n\n    local results = templates.process(\"some-page.tt2\",\n                                      { var1 = val1, var2 = val2, ...})\n\nNow you have Lemplate support for these templates in your OpenResty application.\n\n[Back to TOC](#table-of-contents)\n\n# Public API\n\nThe Lemplate Lua runtime module has the following API method:\n\n- process(template-name, data)\n\n    The `template-name` is a string like `'body.tt2'` that is the name of\n    the top level template that you wish to process.\n\n    The optional `data` specifies the data object to be used by the\n    templates. It can be an object, a function or a url. If it is an object,\n    it is used directly. If it is a function, the function is called and the\n    returned object is used.\n\n[Back to TOC](#table-of-contents)\n\n# Current Support\n\nThe goal of Lemplate is to support all of the Template Toolkit features\nthat can possibly be supported.\n\nLemplate now supports almost all the TT directives, including:\n\n    * Plain text\n    * [% [GET] variable %]\n    * [% [SET] variable = value %]\n    * [% DEFAULT variable = value ... %]\n    * [% INCLUDE [arguments] %]\n    * [% PROCESS [arguments] %]\n    * [% BLOCK name %]\n    * [% IF condition %]\n    * [% ELSIF condition %]\n    * [% ELSE %]\n    * [% FOR x = y %]\n    * [% FOR x IN y %]\n    * [% WHILE expression %]\n    * [% NEXT %]\n    * [% LAST %]\n    * [%# this is a comment %]\n\nALL of the string virtual functions are supported.\n\nALL of the array virtual functions are supported:\n\nALL of the hash virtual functions are supported:\n\nMANY of the standard filters are implemented.\n\nThe remaining features will be added very soon. See the DESIGN document\nin the distro for a list of all features and their progress.\n\n[Back to TOC](#table-of-contents)\n\n# Community\n\n## English Mailing List\n\nThe [openresty-en](https://groups.google.com/group/openresty-en) mailing list is for English speakers.\n\n[Back to TOC](#table-of-contents)\n\n## Chinese Mailing List\n\nThe [openresty](https://groups.google.com/group/openresty) mailing list is for Chinese speakers.\n\n[Back to TOC](#table-of-contents)\n\n# Code Repository\n\nThe bleeding edge code is available via Git at\ngit://github.com/openresty/lemplate.git\n\n[Back to TOC](#table-of-contents)\n\n# Bugs and Patches\n\nPlease submit bug reports, wishlists, or patches by\n\n1. creating a ticket on the [GitHub Issue Tracker](https://github.com/openresty/lua-nginx-module/issues),\n2. or posting to the [\"Community\"](#community).\n\n[Back to TOC](#table-of-contents)\n\n# Credit\n\nThis project is based on Ingy dot Net's excellent [Jemplate](https://metacpan.org/pod/Jemplate) project.\n\n[Back to TOC](#table-of-contents)\n\n# Author\n\nYichun Zhang (agentzh), \u003cagentzh@gmail.com\u003e, OpenResty Inc.\n\n[Back to TOC](#table-of-contents)\n\n# Copyright\n\nCopyright (C) 2016-2017 Yichun Zhang (agentzh).  All Rights Reserved.\n\nCopyright (C) 1996-2014 Andy Wardley.  All Rights Reserved.\n\nCopyright (c) 2006-2014. Ingy döt Net. All rights reserved.\n\nCopyright (C) 1998-2000 Canon Research Centre Europe Ltd\n\nThis module is free software; you can redistribute it and/or modify it under\nthe same terms as Perl itself.\n\n[Back to TOC](#table-of-contents)\n\n# See Also\n\n- Perl TT2 Reference Manual: http://www.template-toolkit.org/docs/manual/index.html\n- Jemplate for compiling TT2 templates to client-side JavaScript: http://www.jemplate.net/\n\n[Back to TOC](#table-of-contents)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenresty%2Flemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenresty%2Flemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenresty%2Flemplate/lists"}