{"id":18309986,"url":"https://github.com/ne-smalltown/red-lotus","last_synced_at":"2026-04-18T09:31:44.643Z","repository":{"id":57349489,"uuid":"302274290","full_name":"NE-SmallTown/red-lotus","owner":"NE-SmallTown","description":"A react renderer for generating a template project using Node.js!","archived":false,"fork":false,"pushed_at":"2020-10-31T07:22:30.000Z","size":398,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-04T20:40:39.332Z","etag":null,"topics":["react","react-renderer","reactjs","scaffold","template-engine"],"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/NE-SmallTown.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-08T08:16:06.000Z","updated_at":"2023-03-10T08:37:47.000Z","dependencies_parsed_at":"2022-09-09T15:11:30.191Z","dependency_job_id":null,"html_url":"https://github.com/NE-SmallTown/red-lotus","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NE-SmallTown%2Fred-lotus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NE-SmallTown%2Fred-lotus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NE-SmallTown%2Fred-lotus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NE-SmallTown%2Fred-lotus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NE-SmallTown","download_url":"https://codeload.github.com/NE-SmallTown/red-lotus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248033332,"owners_count":21036773,"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":["react","react-renderer","reactjs","scaffold","template-engine"],"created_at":"2024-11-05T16:12:55.819Z","updated_at":"2026-04-18T09:31:44.595Z","avatar_url":"https://github.com/NE-SmallTown.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# red-lotus\n\nA tiny engine of file and template generation implemented by react-renderer for Node.js.\n\nThis project is inspired by a [tweet](https://twitter.com/dan_abramov/status/1285471956305956864) of Dan Abramov.\n\n# Motivation\n\nToday, the normal way to create a file and fill some text into it is directly call the node API like `fs.writeFileSync`.\nAt most time it's ok, but for a complex (node)library especially for a scaffold, it's hard and annoying to create and concat\nthe file content. That's why we often use a template engine to do this. And then we have to maintain a lot of\ntemplate engine logic/syntax(condition, iteration, ...) and constant variables like `{{ NAMESPACE_FOO_OPTION_BAR }}` in that file.\n\nIf so, how we maintain those variables/logic? And how we communicate them with all kinds of upstream/libs?\n\nThat bothers me, so I create red-lotus.\n\n# Installation\n\n`npm i red-lotus red-lotus-cli`\n\n# Usage\n\n## Use it out of box\n\n```javascript\n// index.js\n\nconst path = require('path');\nconst React = require('react');\nconst RedLotus = require('red-lotus');\n\nconst { File, Content } = RedLotus\n\nfunction HelloFile(props) {\n  const { platform } = props;\n\n  return (\n    React.createElement(\n      File,\n      { path: 'hello.js' },\n      React.createElement(\n        Content,\n        null,\n        `console.log('${ platform === 'node' ? 'Hello Node!' : 'Hello React!' }');`\n      )\n    )\n  );\n}\n\nconst rootContainer = path.resolve(__dirname, 'this-is-the-generation-result-root-path');\n\nRedLotus.render(React.createElement(HelloFile, { platform: 'node' }), rootContainer);\n```\n\nThe result will be:\n\n```bash\nroot\n   |-- this-is-the-generation-result-root-path\n   |   |-- hello.js\n```\n\n```javascript\n// hello.js\n\nconsole.log('Hello Node!');\n```\n\nAfter run `node ./index.js`, you will see that there will be a directory named `this-is-the-generation-result-root-path`\nwhich has a `hello.js` file in it. And the content of `hello.js` is `console.log('Hello Node!');`.\n\n## Use ES Module and JSX by `red-lotus-cli`\n\nThe above example don't use JSX and ES Module because Node doesn't support them natively at now.\n\nBut of course you can write ES Module and JSX and then compile it to the syntax supported by Node by using a tool like Babel.\n\nAlso, you can use red-lotus-cli which helps you do that.\n\nAll you need to do is write a `red-lotus.config.js` in your root path:\n\n```javascript\n// red-lotus.config.js\n\nconst path = require('path');\n\nmodule.exports = {\n  entry: path.resolve(__dirname, './src/index.js'),\n};\n```\n\nAnd then run `npx redlotus start` or add `\"wooo\": \"redlotus start\"` into the `scripts` field of your `package.json` and\nthen run `npm run wooo`.\n\nIt will works same as the above example.\n\nYou can find a whole example [here](./examples/basic).\n\n# Supported Environments\n\n- Node.js 10+\n- Chrome (WIP)\n\n# How it works\n\nTBD\n\n# Contributing\n\nTBD\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fne-smalltown%2Fred-lotus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fne-smalltown%2Fred-lotus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fne-smalltown%2Fred-lotus/lists"}