{"id":16788784,"url":"https://github.com/ayakovlenko/wf-go","last_synced_at":"2025-04-10T23:25:11.575Z","repository":{"id":89280439,"uuid":"265355924","full_name":"ayakovlenko/wf-go","owner":"ayakovlenko","description":"organize your brain… as code","archived":false,"fork":false,"pushed_at":"2024-05-07T20:52:02.000Z","size":51,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T20:12:31.443Z","etag":null,"topics":["cli","workflowy"],"latest_commit_sha":null,"homepage":"https://workflowy.com","language":"Go","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/ayakovlenko.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-19T20:17:56.000Z","updated_at":"2024-05-07T20:52:06.000Z","dependencies_parsed_at":"2025-02-18T05:31:36.724Z","dependency_job_id":"a2ad4a4a-f91d-4865-8dac-1f6de7ed904c","html_url":"https://github.com/ayakovlenko/wf-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayakovlenko%2Fwf-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayakovlenko%2Fwf-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayakovlenko%2Fwf-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayakovlenko%2Fwf-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayakovlenko","download_url":"https://codeload.github.com/ayakovlenko/wf-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248313652,"owners_count":21082892,"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":["cli","workflowy"],"created_at":"2024-10-13T08:24:46.775Z","updated_at":"2025-04-10T23:25:11.559Z","avatar_url":"https://github.com/ayakovlenko.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wf\n\n_organize your brain… as code_\n\n`wf` can generate [WorkFlowy](https://workflowy.com) templates with arbitrary\nlogic.\n\nBy convention, templates must reside in `$WF_DIR/templates`, and the only\nrequirement is that they must return `Item` object.\n\nThe simplest possible template is:\n\n```js\nItem(\"Hello, World!\");\n```\n\nYou can use any valid JS as long as it's ES 5.1.\nUnder the hood, `wf` relies on [dop251/goja][goja] package which supports only\nES 5.1 yet.\n\n```sh\nWF_DIR=\"$(pwd)/examples\" ./run tpl daily\n```\n\n```js\n// $WF_DIR/templates/daily.js\nvar date = new Date();\n\nvar isoDate = date.toISOString().split(\"T\")[0];\n\nvar todo = Item(\"To do today\");\n\nif (date.isSaturday()) {\n  todo.add(Item(\"Laundry\"));\n}\n\nif (date.isMonday() || date.isWednesday() || date.isFriday()) {\n  todo.add(\n    Item(\"Workout\", [\n      Item(\"Push-ups\"),\n      Item(\"Squats\"),\n      Item(\"Plank\"),\n    ])\n  );\n}\n\nItem(\n  isoDate,\n  date.getDayName(),\n  [\n    Item(\"Menu\"),\n    todo,\n  ]\n);\n```\n\nTo use the template, run `wf template` command giving a name of the template\nfile without `.js` extension:\n\n```\n$ wf template daily\n```\n\nThe output of the command will be:\n\n```xml\n\u003copml version=\"1.0\"\u003e\n  \u003cbody\u003e\n    \u003coutline text=\"2020-05-15\" _note=\"Saturday\"\u003e\n      \u003coutline text=\"Menu\"\u003e\n        \u003coutline text=\"Meat\"\u003e\u003c/outline\u003e\n      \u003c/outline\u003e\n      \u003coutline text=\"To do today\"\u003e\n        \u003coutline text=\"Laundry\"\u003e\u003c/outline\u003e\n      \u003c/outline\u003e\n    \u003c/outline\u003e\n  \u003c/body\u003e\n\u003c/opml\u003e\n```\n\nWhen you paste this XML is into WorkFlowy, it's going to be transformed into\na nice-looking list:\n\n![](https://i.imgur.com/kTOwuIr.png)\n\n## Templates\n\n### Item DSL\n\nYou have 4 overloaded functions to define items:\n\n```ts\nfunction Item(title: string): Item\n\nfunction Item(title: string, note: string): Item\n\nfunction Item(title: string, items: Array\u003cItem\u003e): Item\n\nfunction Item(title: string, note: string, items: Array\u003cItem\u003e): Item\n```\n\n### Built-in functions\n\n```js\nDate.prototype.getDayName\n\nDate.prototype.isMonday\n\nDate.prototype.isTuesday\n\nDate.prototype.isWednesday\n\nDate.prototype.isThursday\n\nDate.prototype.isFriday\n\nDate.prototype.isSaturday\n\nDate.prototype.isSunday\n\nDate.prototype.getDayName\n```\n\n### Built-in constants\n\n```js\nconst MONDAY    = 1;\nconst TUESDAY   = 2;\nconst WEDNESDAY = 3;\nconst THURSDAY  = 4;\nconst FRIDAY    = 5;\nconst SATURDAY  = 6;\nconst SUNDAY    = 7;\n```\n\n### Parameters\n\nTemplate parameters are passed after template name and have the following\nsyntax:\n\n```bash\n$ wf template \u003cname\u003e [key=value ...]\n```\n\nExample:\n\n```bash\n$ wf template daily date=tomorrow\n```\n\nTo access parameters in templates, use global `param` object:\n\n```js\nvar date = new Date();\n\nif (param.date === \"tomorrow\") {\n  date.setDate(date.getDate() + 1);\n}\n```\n\n[goja]: https://github.com/dop251/goja\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayakovlenko%2Fwf-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayakovlenko%2Fwf-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayakovlenko%2Fwf-go/lists"}