{"id":21428340,"url":"https://github.com/ushelp/easytemplatejs-express","last_synced_at":"2025-03-16T21:25:30.713Z","repository":{"id":57218965,"uuid":"145061418","full_name":"ushelp/EasyTemplateJS-express","owner":"ushelp","description":"EasyTemplateJS template engine middleware for express!","archived":false,"fork":false,"pushed_at":"2020-11-17T08:25:31.000Z","size":998,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T16:33:51.697Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ushelp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["http://www.easyproject.cn/donation"]}},"created_at":"2018-08-17T02:24:45.000Z","updated_at":"2020-11-17T08:25:33.000Z","dependencies_parsed_at":"2022-08-28T21:41:13.524Z","dependency_job_id":null,"html_url":"https://github.com/ushelp/EasyTemplateJS-express","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushelp%2FEasyTemplateJS-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushelp%2FEasyTemplateJS-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushelp%2FEasyTemplateJS-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushelp%2FEasyTemplateJS-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ushelp","download_url":"https://codeload.github.com/ushelp/EasyTemplateJS-express/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243934260,"owners_count":20371153,"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-22T22:12:48.949Z","updated_at":"2025-03-16T21:25:30.687Z","avatar_url":"https://github.com/ushelp.png","language":"JavaScript","funding_links":["http://www.easyproject.cn/donation"],"categories":[],"sub_categories":[],"readme":"# EasyTemplateJS-express\n\n**EasyTemplateJS-express 是基于 [EasyTemplateJS](https://github.com/ushelp/EasyTemplateJS \"EasyTemplateJS\") 的 [Express](http://expressjs.com/ \"Express\") 框架的模板引擎中间件。**\n\n**EasyTemplateJS-express is a template engine middleware based on [EasyTemplateJS](https://github.com/ushelp/EasyTemplateJS \"EasyTemplateJS\")  for the [Express](http://expressjs.com/ \"Express\") framework.**\n\n\n\n## Npm install\n\n```BASH\nnpm install easytemplatejs-express \n```\n\t\n## Usage\n\n```JS\nconst app = express();\n\n// EasyTemplateJS-express\nconst view = require('easytemplatejs-express');\n\n// EasyTemplateJS-Express view render middleware\nview(app, {\n    cache: true,  // Whether to open the cache; default is true\n    //cache: process.env.NODE_ENV == 'production',\n    enableScript:true, // enable \u003cetj-script\u003e; default is true\n    enableStyle:true, // enable \u003cetj-style\u003e; default is true\n    views: './views'  // template file directory\n});\n```\n\n## Demo\n\n- **app.js**\n\n\t```JS\n\tconst express = require('express')\n\tconst app = express() \n\t\n\t// EasyTemplateJS-express\n\tconst view = require('easytemplatejs-express');\n\t// EasyTemplateJS-Express view render middleware\n\tview(app, {\n\t\tviews: './views'  // template file directory\n\t});\n\t\n\t\n\tapp.get('/users', function (req, res) {\n\t  res.render('user', {\n\t        name: 'Jay',\n\t\t\tlist:[\n\t \t\t\t{name:\"Jay\", sex:'M'},\n\t \t\t\t{name:\"Rose\", sex:'F'},\n\t \t\t\t{name:\"Anna \", sex:'F'}\n\t \t\t]\n\t\t});\n\t})\n\t\n\tapp.listen(3000, function () { console.log('App listening on port 3000!') })\n\n\t```\n\n- **./views/user.etj**\n\n\t```HTML\n\t\u003ch1\u003eHello {=name}!\u003c/h1\u003e\n\t\u003cul\u003e\n\t%{\n\t\tfor(var i=0;i\u003clist.length;i++){\n\t\t\tout('\u003cli\u003e'+list[i].name+\", \"+list[i].sex+'\u003c/li\u003e');\t\n\t\t}\n\t}%\n\t\u003c/ul\u003e\n\t```\n\t\n\n## EasyTemplateJS Core Object\n\n如果需要获得 EasyTemplateJS 的核心对象进行调用，可通过中间件函数的 `.templateEngine` 属性获得。\n\nIf you need to get the core object of EasyTemplateJS to make a call, you can get it use the `.templateEngine` property of the middleware function.\n\n```JS\nconst view = require('easytemplatejs-express');\n\n// Get EasyTemplate core Object\nvar Et=view.templateEngine;\n\n// Use Et\nEt.tmplSettings={\n\t// 脚本表达式开始结束标记%{ JS script }%\n\tscriptBegin:\"%{\",\n\tscriptEnd:\"}%\",\n\t// 输出表达式开始结束标记 {name}\n\toutBegin:\"{=\",\n\toutEnd:\"}\",\n\t// 转义输出表达式开始结束标记 {-name}\n\tescapeOutBegin:\"{-\",\n\tescapeOutEnd:\"}\"\n}\n```\n\t\n\t\n## 内嵌 Script 和 CSS 支持/Embedded JavaScript and CSS\n\n```javascript\nview(app, {\n  enableScript:true, // enable \u003cetj-script\u003e; default is true\n  enableStyle:true, // enable \u003cetj-style\u003e; default is true\n  ...\n});\n```\n\n\n#### 中文\n\n为了增强在 Express 等服务端 Web 应用框架中使用模板的功能体验，EasyTemplateJS 开创性的为模板提供了 script 脚本和 style 样式表支持。\n- **Script 代码支持**\n\n\t将 JavaScript 代码放在 `\u003cetj-script\u003e` ... `\u003c/etj-script\u003e` 标签之间。 **语句必须使用 `;` 结尾。**\n\t\n\t\n- **CSS 代码支持**\n\t\t\n\t将 CSS 代码放在 `\u003cetj-style\u003e` ... `\u003c/etj-style\u003e` 标签之间。\n\t\n\n#### English\n\nTo enhance the functional experience of using templates in Express and other server-side Web application frameworks, EasyTemplateJS pioneered the provision of script scripts and style style sheet support for templates.\n\n- **Script code support**\n\n\tPlace the JavaScript code between the `\u003cetj-script\u003e` ... `\u003c/etj-script\u003e` tags. **The statement must end with `;`.**\n\t\n\t\n- **CSS  code support**\n\t\t\n\tPlace the CSS code between the `\u003cetj-style\u003e` ... `\u003c/etj-style\u003e` tags.\n\n\t\n\t\n\n## EasyTemplateJS\n\n[Documents](https://github.com/ushelp/EasyTemplateJS \"EasyTemplateJS\")\n\n## End\n\nEmail：\u003cinthinkcolor@gmail.com\u003e\n\n[http://www.easyproject.cn](http://www.easyproject.cn \"EasyProject Home\")\n\n\n**Donation/捐助:**\n\n\u003ca href=\"http://www.easyproject.cn/donation\"\u003e\n\u003cimg alt=\"\n支付宝/微信/QQ/云闪付/PayPal 扫码支付\" src=\"http://www.easyproject.cn/thanks/donation.png\"  title=\"支付宝/微信/QQ/云闪付/PayPal 扫码支付\"  height=\"320\" width=\"320\"\u003e\u003c/img\u003e\u003c/a\u003e\n\u003cdiv\u003e支付宝/微信/QQ/云闪付/PayPal\u003c/div\u003e\n\n\u003cbr/\u003e\n\n我们相信，每个人的点滴贡献，都将是推动产生更多、更好免费开源产品的一大步。\n\n**感谢慷慨捐助，以支持服务器运行和鼓励更多社区成员。**\n\nWe believe that the contribution of each bit by bit, will be driven to produce more and better free and open source products a big step.\n\n**Thank you donation to support the server running and encourage more community members.**\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fushelp%2Feasytemplatejs-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fushelp%2Feasytemplatejs-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fushelp%2Feasytemplatejs-express/lists"}