{"id":21405341,"url":"https://github.com/karimsa/pennyworth","last_synced_at":"2025-03-16T16:50:59.145Z","repository":{"id":35594844,"uuid":"39867784","full_name":"karimsa/pennyworth","owner":"karimsa","description":"a natural language templating engine for alfred","archived":false,"fork":false,"pushed_at":"2016-06-29T09:12:12.000Z","size":40,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T21:03:58.207Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karimsa.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-07-29T02:03:48.000Z","updated_at":"2016-12-21T04:16:04.000Z","dependencies_parsed_at":"2022-08-25T22:42:08.146Z","dependency_job_id":null,"html_url":"https://github.com/karimsa/pennyworth","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fpennyworth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fpennyworth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fpennyworth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fpennyworth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karimsa","download_url":"https://codeload.github.com/karimsa/pennyworth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902293,"owners_count":20366259,"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-22T16:24:19.031Z","updated_at":"2025-03-16T16:50:59.102Z","avatar_url":"https://github.com/karimsa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pennyworth [![Build Status](https://travis-ci.org/karimsa/pennyworth.svg)](https://travis-ci.org/karimsa/pennyworth)\n\na natural language templating engine\n\n[![NPM](https://nodei.co/npm/pennyworth.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/pennyworth/)\n\n## usage\n\n```javascript\n// build a template from a template string\nvar template = pennyworth.template('my $adjective template.');\n\n// the template is a function that can be called with data at\n// any time and multiple times\ntemplate('my beautiful template').then(function (compiled) {\n\t// it will always return a promise to allow support for\n\t// asynchronous filters\n\n\tconsole.log(compiled); // { adjective : 'beautiful' }\n});\n```\n\n## spec\n\n### variables\n\ntemplate: `hello, $who.`\n\n- for `hello, alfred` =\u003e $who = `alfred`\n- for `hello, alfred. how are you?` =\u003e $who = `alfred how are you`\n- for `hello, how are you?` =\u003e $who = `how are you`\n\ntemplate: `hello, $who. how are you?`\n\n- for `hello, alfred.` =\u003e $who = `alfred`\n- for `hello, alferd. how are you?` =\u003e $who = `alfred`\n- for `hello, how are you?` =\u003e $who = ``\n\n### variable filters\n\ntemplate: `i am $x years old.`\n\n- for `i am 18 years old.` =\u003e $x = \"18\"\n\ntemplate: `i am $x:int years old.`\n\n- for `i am 18 years old` =\u003e $x = 18\n\n*Supported filters: string, int, float, word.*\n\nAdding a new filter:\n\n```javascript\npennyworth.filter('my-new-filter', function ( input ) {\n\treturn String(input) + '!';\n});\n\nvar template = pennyworth.template('hello, $who:my-new-filter.');\ntemplate('hello, alfred.').who === 'alfred!'; // true\n```\n\nFor asynchronous filters, grab a callback using this.async():\n\n```javascript\npennyworth.filter('async', function ( input ) {\n\tlet done = this.async();\n\tdone( error , filtered );\n});\n``` \n\n## named entities\n\npennyworth uses the Stanford NER for named entity filters.\n\n*Supported filters (from the 7 class model): Location, Person, Organization, Money, Percent, Date, Time*\n\nTo use any, just use the entity type as the filter name:\n\nFor instance, for the input string `My name is Alfred Pennyworth not Wayne Mansion.`, if you use the filter\n'string': `My name is $name:string` then the resolved name will be \"Alfred Pennyworth not Wayne Mansion\". But\nif you use the filter 'person', the output will be \"Alfred Pennyworth\".\n\n## expander\n\nto expand a set of arguments, use curly braces:\n\n - `{hey, hi, hello}, there` will expand to:\n  - hey, there.\n  - hi, there.\n  - hello, there.\n\n## conditional\n\nto make a part of the expansion conditional, use a question mark:\n\n - `i am $age {years?}` expands to:\n  - i am $age\n  - i am $age years\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarimsa%2Fpennyworth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarimsa%2Fpennyworth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarimsa%2Fpennyworth/lists"}