{"id":13624753,"url":"https://github.com/baryshev/ect","last_synced_at":"2025-04-09T02:18:37.647Z","repository":{"id":4590447,"uuid":"5732788","full_name":"baryshev/ect","owner":"baryshev","description":"Fastest JavaScript template engine with embedded CoffeeScript syntax","archived":false,"fork":false,"pushed_at":"2016-09-26T06:07:18.000Z","size":182,"stargazers_count":622,"open_issues_count":52,"forks_count":69,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-04-01T18:21:35.108Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://ectjs.com","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/baryshev.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":"2012-09-08T22:26:22.000Z","updated_at":"2024-11-28T16:30:35.000Z","dependencies_parsed_at":"2022-08-06T17:00:54.595Z","dependency_job_id":null,"html_url":"https://github.com/baryshev/ect","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/baryshev%2Fect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baryshev%2Fect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baryshev%2Fect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baryshev%2Fect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baryshev","download_url":"https://codeload.github.com/baryshev/ect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247962605,"owners_count":21024871,"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-01T21:01:45.943Z","updated_at":"2025-04-09T02:18:37.629Z","avatar_url":"https://github.com/baryshev.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# ECT\n\n[Performance focused](http://ectjs.com/#benchmark) JavaScript template engine with embedded CoffeeScript syntax.\n\n[Just try demo](http://ectjs.com) to check all features.\n\n## Installation\n\n\tnpm install ect\n\n## Features\n\n  * Excellent performance\n  * Templates caching\n  * Automatic reloading of changed templates\n  * CoffeeScript code in templates\n  * Multi-line expressions support\n  * Tag customization support\n  * Node.JS and client-side support\n  * Powerful but simple syntax\n  * Inheritance, partials, blocks\n  * Compatible with `express`\n  * Compatible with `RequireJS`\n  * Backward compatible with `eco`\n  * [Syntax highlighting for Sublime Text 2](https://github.com/TurtlePie/Sublime-ECT) by [TurtlePie](https://github.com/TurtlePie)\n\n## Usage\n\n```js\nvar ECT = require('ect');\n\nvar renderer = ECT({ root : __dirname + '/views', ext : '.ect' });\nvar html = renderer.render('page', { title: 'Hello, World!' });\n```\n\nor\n\n```js\nvar ECT = require('ect');\n\nvar renderer = ECT({ root : __dirname + '/views', ext : '.ect' });\n\nrenderer.render('page', { title: 'Hello, World!' }, function (error, html) {\n\tconsole.log(error);\n\tconsole.log(html);\n});\n```\n\nYou may use JavaScript object as root.\n\n```js\nvar ECT = require('ect');\n\nvar renderer = ECT({ root : {\n\t\t\t\tlayout: '\u003chtml\u003e\u003chead\u003e\u003ctitle\u003e\u003c%- @title %\u003e\u003c/title\u003e\u003c/head\u003e\u003cbody\u003e\u003c% content %\u003e\u003c/body\u003e\u003c/html\u003e',\n\t\t\t\tpage: '\u003c% extend \"layout\" %\u003e\u003cp\u003ePage content\u003c/p\u003e'\n\t\t\t\t}\n\t\t\t});\n\nvar html = renderer.render('page', { title: 'Hello, World!' });\n```\n\n### With express\n\napp.js\n```js\nvar express = require('express');\nvar app = express();\nvar ECT = require('ect');\nvar ectRenderer = ECT({ watch: true, root: __dirname + '/views', ext : '.ect' });\n\napp.set('view engine', 'ect');\napp.engine('ect', ectRenderer.render);\n\napp.get('/', function (req, res){\n\tres.render('index');\n});\n\napp.listen(3000);\nconsole.log('Listening on port 3000');\n```\n\nviews/index.ect\n```html\n\u003c% extend 'layout' %\u003e\n\u003c% include 'extra' %\u003e\n\u003cdiv\u003eHello, World!\u003c/div\u003e\n```\n\nviews/extra.ect\n```html\n\u003cdiv\u003eInclude me!\u003c/div\u003e\n```\n\nviews/layout.ect\n```html\n\u003chtml\u003e\n\t\u003cbody\u003e\n\t\t\u003c% content %\u003e\n\t\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Syntax\n\n### Unescaped output\n\n```\n\u003c%- someVar %\u003e\n```\n\n### Escaped output\n\n```\n\u003c%= someVar %\u003e\n```\n\n### CoffeeScript code\n\n```\n\u003c% for article in @articles : %\u003e\n\t\u003c% include 'article', article %\u003e\n\u003c% end %\u003e\n```\n\nor\n\n```\n\u003c% if @user?.authenticated : %\u003e\n\t\u003c% include 'partials/user' %\u003e\n\u003c% else : %\u003e\n\t\u003c% include 'partials/auth' %\u003e\n\u003c% end %\u003e\n```\n\n### Inheritance\n\n```\n\u003c% extend 'layout' %\u003e\n```\n\nUse\n\n\n```\n\u003c% content %\u003e\n```\n\nin parent template to define the insertion point.\n\n### Partials\n\n```\n\u003c% include 'partial' %\u003e\n```\n\nYou can redefine data context of partial\n\n```\n\u003c% include 'partial', { customVar: 'Hello, World!' } %\u003e\n```\n\n### Blocks\n\n```\n\u003c% block 'blockName' : %\u003e\n\t\u003cp\u003eThis is block content\u003c/p\u003e\n\u003c% end %\u003e\n```\n\nUse\n\n\n```\n\u003c% content 'blockName' %\u003e\n```\n\nin parent template to define the insertion point.\n\nBlocks supports more than one level of inheritance and may be redefined.\n\n## Options\n\n### Renderer\n\n  - `root` — Templates root folder or JavaScript object containing templates\n  - `ext` — Extension of templates, defaulting to `''` (not used for JavaScript objects as root)\n  - `cache` — Compiled functions are cached, defaulting to `true`\n  - `watch` — Automatic reloading of changed templates, defaulting to `false` (useful for debugging with enabled cache, not supported for client-side)\n  - `open` — Open tag, defaulting to `\u003c%`\n  - `close` — Closing tag, defaulting to `%\u003e`\n\n### Compiler middleware\n\n  - `root` — Base url, defaulting to `/` (should be equal to `root` option on the client side)\n  - `gzip` — Compressing templates with gzip, defaulting to `false`\n\n## Client-side support\n\nDownload and include [coffee-script.js](https://github.com/jashkenas/coffee-script/blob/master/extras/coffee-script.js) and [ect.min.js](https://github.com/baryshev/ect/tree/master/ect.min.js).\n\n```html\n\u003cscript src=\"/path/coffee-script.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"/path/ect.min.js\"\u003e\u003c/script\u003e\n```\n\nUse it.\n\n```js\nvar renderer = ECT({ root : '/views' });\nvar data = { title : 'Hello, World!' };\nvar html = renderer.render('template.ect', data);\n```\n\n### With server side compiler middleware\n\nDownload and include [ect.min.js](https://github.com/baryshev/ect/tree/master/ect.min.js). You don't need to include CoffeeScript compiler, because templates are served already compiled by server side compiler middleware.\n\n```html\n\u003cscript src=\"/path/ect.min.js\"\u003e\u003c/script\u003e\n```\n\nSetup server side compiler middleware.\n\n```js\nvar connect = require('connect');\nvar ECT = require('ect');\n\nvar renderer = ECT({ root : __dirname + '/views', ext : '.ect' });\n\nvar app = connect()\n\t.use(renderer.compiler({ root: '/views', gzip: true }))\n\t.use(function(err, req, res, next) {\n\t\tres.end(err.message);\n\t});\n\napp.listen(3000);\n```\n\nUse it.\n\n```js\nvar renderer = ECT({ root : '/views', ext : '.ect' });\nvar data = { title : 'Hello, World!' };\nvar html = renderer.render('template', data);\n```\n\nNote: root folder must be on the same domain to avoid cross-domain restrictions.\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 Vadim M. Baryshev \u0026lt;vadimbaryshev@gmail.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaryshev%2Fect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaryshev%2Fect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaryshev%2Fect/lists"}