{"id":15950713,"url":"https://github.com/magicdawn/ractive-engine","last_synced_at":"2026-01-19T04:30:17.423Z","repository":{"id":29886784,"uuid":"33432221","full_name":"magicdawn/ractive-engine","owner":"magicdawn","description":"Template engine for node.js with Ractive.js","archived":false,"fork":false,"pushed_at":"2017-04-08T23:55:41.000Z","size":156,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-05T08:37:08.775Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/magicdawn.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":"2015-04-05T06:08:33.000Z","updated_at":"2015-05-07T14:22:20.000Z","dependencies_parsed_at":"2022-08-03T13:30:08.866Z","dependency_job_id":null,"html_url":"https://github.com/magicdawn/ractive-engine","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/magicdawn%2Fractive-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fractive-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fractive-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fractive-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicdawn","download_url":"https://codeload.github.com/magicdawn/ractive-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239515151,"owners_count":19651710,"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-10-07T13:00:07.613Z","updated_at":"2026-01-19T04:30:17.343Z","avatar_url":"https://github.com/magicdawn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ractive-engine\nTemplate engine for node.js with Ractive.js.\n\n[![Build Status](https://travis-ci.org/magicdawn/ractive-engine.svg?branch=master)](https://travis-ci.org/magicdawn/ractive-engine)\n[![Coverage Status](https://coveralls.io/repos/magicdawn/ractive-engine/badge.svg?branch=master)](https://coveralls.io/github/magicdawn/ractive-engine?branch=master)\n\nFeatures like\n- extend/block in [jade](http://jade-lang.com/) or\n- layout/renderBody section/renderSection in [ASP.NET MVC Razor](http://www.asp.net/web-pages/overview/getting-started/introducing-razor-syntax-(c))\n\nare supported. Actually they are the same thing.\n\n## Install\n```shell\nnpm i ractive-engine --save\n```\n\n## API\n```js\n// the default export engine\n// instance of RactiveEngine with default options\nvar ractive = require('ractive-engine');\n\n// RactiveEngine class definition\nvar RactiveEngine = require('ractive-engine').RactiveEngine;\n\n// Ractive class used by this library\nvar Ractive = require('ractive-engine').Ractive;\n```\n\n### ractive.renderFile\nractive.renderFile(viewPath,locals) =\u003e result\n\nIt's synchronous,but view cache will be auto enabled when NODE_ENV set to production.\n\n### RactiveEngine class options\n- enableCache : whether enable view cache, if not specify explicitly , it's decided by `NODE_ENV === production`\n\n- ext : extension of view file,for engine look up files when ignore extension, defaults to `.html`\n\n- layoutRoot : where to find layouts\n\t- `{{extend './main'}}`, `./main` is relative to the file.\n\n\t- `{{#extend main}}{{/extend}}`,  layoutRoot is required here\n\t\tand layout resolve to `\u003clayoutRoot\u003e/main`\n\n- partialRoot : where to find partials\n\t- `{{\u003epartials.some.partial}}`\n\t\tpartialRoot is required here,since it's built in Ractive , Use `{{#include relativePath}}`,will resolve to `\u003cpartialRoot\u003e/partials/some/partial\u003e`\n\t\t\n\t- `{{#include './partials/some/partial'}}` \n\t\tIt's same to use `{{\u003e...}}`,but this can include a relative path\n\n### express support\n```js\n// app is express app\napp.engine('.html',require('ractive-engine').express(options));\n```\n\n## Syntaxs\n\n### extend\n```html\n{{#extend someLayout}}\n{{/extend}}\n```\n\n### block\n```html\n{{#block body}}\n{{/block}}\n```\n\n```html\n{{#prepend someBlock}}\n{{/prepend}}\n```\n\n```html\n{{#append someBlock}}\n{{#/append}}\n```\n\nIt's processed recursivly,that's same to jade's behavior.\n#### for example:\n\nlayout.html\n```html\n\u003chtml\u003e\n\u003chead\u003e\u003ctitle\u003e{{#block title}}{{/block}}\u003c/title\u003e\u003c/head\u003e\n\u003cbody\u003e\n\t\u003cheader\u003e\n\t{{#block header}}\n\t{{/block}}\n\t\u003c/header\u003e\n\t\n\t\u003cdiv\u003e\n\t{{#block body}}\n\t\u003c/div\u003e\n\t\n\t\u003cfooter\u003e\n\t{{#block footer}}\n\t{{/block}}\n\t\u003c/footer\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nindex.html\n```html\n{{#extend './layout'}}\n{{/extend}}\n\n{{#block title}}\nI'm the title\n{{/block}}\n\n{{#block header}}\nI will be the header.\n{{/block}}\n\n{{#block body}}\nI'll be in body.\n{{/block}}\n\n{{#block footer}}\nI will be the footer\n{{/block}}\n```\nwill get\n```html\n\u003chtml\u003e\n\u003chead\u003e\u003ctitle\u003eI'm the title\u003c/title\u003e\u003c/head\u003e\n\u003cbody\u003e\n\t\u003cheader\u003e\n\tI will be the header.\n\t\u003c/header\u003e\n\t\n\t\u003cdiv\u003e\n\tI'll be in body.\n\t\u003c/div\u003e\n\t\n\t\u003cfooter\u003e\n\tI will be the footer\n\t\u003c/footer\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Other Ractive support syntax\ncheck http://docs.ractivejs.org/latest/templates\n\n# TODO\n- [ ] upgrade Ractive to v0.7.x\n- [ ] add some benchmark\n\n# License\nthe MIT License http://magicdawn.mit-license.org","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicdawn%2Fractive-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicdawn%2Fractive-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicdawn%2Fractive-engine/lists"}