{"id":21461771,"url":"https://github.com/appletjs/tpler","last_synced_at":"2026-01-03T16:39:44.314Z","repository":{"id":14226899,"uuid":"16933892","full_name":"appletjs/tpler","owner":"appletjs","description":null,"archived":false,"fork":false,"pushed_at":"2014-02-22T05:52:25.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T14:31:35.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/appletjs.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":"2014-02-18T02:13:31.000Z","updated_at":"2014-02-22T07:18:22.000Z","dependencies_parsed_at":"2022-08-30T09:41:17.792Z","dependency_job_id":null,"html_url":"https://github.com/appletjs/tpler","commit_stats":null,"previous_names":["japplet/tpler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appletjs%2Ftpler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appletjs%2Ftpler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appletjs%2Ftpler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appletjs%2Ftpler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appletjs","download_url":"https://codeload.github.com/appletjs/tpler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243976503,"owners_count":20377692,"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-11-23T07:10:53.328Z","updated_at":"2026-01-03T16:39:44.286Z","avatar_url":"https://github.com/appletjs.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tpler\n\n嵌入式的Javascript模板引擎\n\n\n## Installation\n\t\n\t$ npm install tpler\n\n## Features\n\n  * 静态缓存解析后的 JavaScript\n  * 使用 `\u003c%  code %\u003e` 实现 JavaScript 代码嵌套\n  * 使用 `\u003c%= code %\u003e` 打印变量并转义变量值中的 html\n  * 使用 `\u003c%- code %\u003e` 打印却不转义变量值中的 html\n  * 使用 `\u003c%@ name %\u003e` 实现模板之间的嵌套\n  * 使用 `\u003c%~ html %\u003e` 实现 html 插值法打印，将转义 html\n  * 使用 `\u003c%# html %\u003e` 实现 html 插值法打印，不转义 html\n  * 客户端支持\n  * 使用 `-%\u003e` 实现换行符号插入，比如：`\u003c% var hello = 'Hello, tpler' -%\u003e`\n\n## Example\n\n    \u003c% if (user) { %\u003e\n\t    \u003ch2\u003e\u003c%= user.name %\u003e\u003c/h2\u003e\n    \u003c% } %\u003e\n\n## Usage\n\n    tpler.compile(str, options);\n    // =\u003e Function\n\n    tpler.render(str, options);\n    // =\u003e str\n\n## Options\n\n  - `cache`           缓存编译后的函数，需要 `filename` 支持\n  - `filename`        作用于缓存和模板嵌套\n  - `scope`           函数执行上下文\n  - `debug`           调试模式\n  - `open`            开始标签，默认为 `\u003c%`\n  - `close`           标签，默认为 `%\u003e`\n  - `locals`          模板的本地变量集\n  - `*`               其他的为模板的本地变量\n\n## Includes\n\n 模板之间的嵌套仅仅是一种声明，并非 JavaScript 代码，声明嵌套的模板名称是根据字面意思解析得到的，比如 `\u003c% include user/show %\u003e` 表示嵌套模板 `user/show` 或 `user/show.tpler`。\n\n\t\u003cul\u003e\n\t  \u003c% users.forEach(function(user){ %\u003e\n\t    \u003c% include user/show %\u003e\n\t  \u003c% }) %\u003e\n\t\u003c/ul\u003e\n\n## Interpolate\n\n  利用标记 `\u003c%~ html %\u003e` 或 `\u003c%# html %\u003e` 配合标记 `#{variable|state}`实现简单而实用的字符串插值法\n\n\t\u003c%~ \u003ca name='#{link.name}' class='link[\"class\"]'\u003e#{line.content}\u003c/a\u003e %\u003e\n\t// =\u003e \u0026lt;a name='sjz' class='sjz'\u0026gt;转义插值法\u0026lt;/a\u0026gt;\n\n\t\u003c%# \u003ca name='#{link.name}' class='link[\"class\"]'\u003e#{line.content}\u003c/a\u003e %\u003e\n\t// =\u003e \u003ca name='sjz' class='sjz'\u003e不转义插值法\u003c/a\u003e;\n\n## Custom delimiters\n\n  此外可以全局应用自定义分隔符：\n\n    var tpler = require('tpler');\n    tpler.open = '{{';\n    tpler.close = '}}';\n\n  这将使下面的模板有效:\n\n    \u003ch1\u003e{{= title }}\u003c/h1\u003e\n\n## Layouts\n\n  利用 Tpler 的模板嵌套功能，实施\"布局\"，比如只包括页眉和页脚：\n\n\t\u003c%@ head %\u003e\n\t\u003ch1\u003eTitle\u003c/h1\u003e\n\t\u003cp\u003eMy page\u003c/p\u003e\n\t\u003c%@ foot %\u003e\n\n## License \n\n  (The MIT License)\n\t\n\tCopyright(c) 2014 Maofeng Zhang \u003cjapplet@163.com\u003e\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining\n\ta copy of this software and associated documentation files (the\n\t'Software'), to deal in the Software without restriction, including\n\twithout limitation the rights to use, copy, modify, merge, publish,\n\tdistribute, sublicense, and/or sell copies of the Software, and to\n\tpermit persons to whom the Software is furnished to do so, subject to\n\tthe following conditions:\n\t\n\tThe above copyright notice and this permission notice shall be\n\tincluded in all copies or substantial portions of the Software.\n\t\n\tTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\n\tEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n\tMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n\tIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n\tCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n\tTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n\tSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappletjs%2Ftpler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappletjs%2Ftpler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappletjs%2Ftpler/lists"}