{"id":29150561,"url":"https://github.com/roborourke/fumanchu","last_synced_at":"2025-09-01T17:37:05.293Z","repository":{"id":16730149,"uuid":"19487325","full_name":"roborourke/fumanchu","owner":"roborourke","description":"A very lightweight but much less good version of handlebars/mustache","archived":false,"fork":false,"pushed_at":"2014-06-17T17:14:34.000Z","size":224,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T16:12:02.043Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roborourke.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":"2014-05-06T08:47:19.000Z","updated_at":"2014-06-17T17:14:34.000Z","dependencies_parsed_at":"2022-08-04T10:45:26.433Z","dependency_job_id":null,"html_url":"https://github.com/roborourke/fumanchu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/roborourke/fumanchu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Ffumanchu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Ffumanchu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Ffumanchu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Ffumanchu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roborourke","download_url":"https://codeload.github.com/roborourke/fumanchu/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Ffumanchu/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262864258,"owners_count":23376461,"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":"2025-06-30T23:10:53.130Z","updated_at":"2025-06-30T23:10:53.741Z","avatar_url":"https://github.com/roborourke.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"fumanchu\n========\n\nA very lightweight but much less good version of handlebars/mustache.\n\n## Disclaimer\n\nThis was put together as part of a larger project where using handlebars was overkill. This\nlibrary has not been thoroughly tested and the approach to templates for arrays is a bit\nclunky still. Any suggestion or questioning of my sanity is welcome :)\n\n## Usage\n\nFumanchu requires a minimum of 2 parameters. A template string, and an object containing\nthe data used to replace special tags with.\n\nTemplate tags should be placed in double braces `{{key}}` *or* double underscores `__key__`,\nhandy if you're generating URLs.\n\nDouble underscored tags are escaped for URLs using `escape()`.\n\n```js\nvar output = $.fumanchu( '{{title}}', { title: 'Some title' } );\n// output = 'Some title'\n```\n\nFumanchu will search an object up to 3 levels deep to find data.\n\n```js\nvar output = $.fumanchu( '{{level1.level2.level3.data}}', {\n  level1: {\n    level2: {\n\t  level3: {\n\t    data: 'I am 3 levels deep!'\n\t  }\n\t}\n  }\n} );\n// output = 'I am 3 levels deep!'\n```\n\nFumanchu will accept a fallback object too which is used as a backup search.\nItems in the first object with the same name will be used before items in the 2nd.\n\n```js\nvar output = $.fumanchu( '{{title}} by {{author}}', {\n  title: 'Some title'\n}, {\n  title: 'Fallback title'\n  author: 'Robert O\\'Rourke'\n} );\n// output = 'Some title by Robert O\\'Rourke'\n```\n\nTemplates are parsed recursively, this means a value can also contain tags for replacement.\n\n```js\nvar output = $.fumanchu( '{{title}}', {\n  title: 'Some title by {{author}}',\n  author: 'Robert O\\'Rourke'\n} );\n// output = 'Some title by Robert O\\'Rourke'\n```\n\nValues within the hash can be objects, arrays, and even functions.\n\n### Arrays\n\nAn array value will be looped through. The array can just contain strings but typically\nit would be an array of objects. The objects should have a template specified, this lets\nyou modify the template per item if you wish.\n\n```js\nvar output = $.fumanchu( '\u003cul\u003e{{items}}\u003c/ul\u003e', {\n  items: [\n    {\n\t  title: 'Title 1',\n\t  author: 'Joe Pesci',\n\t  template: '\u003cli\u003e{{title}} by {{author}}\u003c/li\u003e'\n\t},\n\t{\n\t  title: 'Title 2',\n\t  author: 'Robert de Niro',\n\t  template: '\u003cli\u003e{{title}} by {{author}}\u003c/li\u003e'\n\t}\n  ]\n} );\n// output = '\u003cul\u003e\u003cli\u003eTitle 1 by Joe Pesci\u003c/li\u003e\u003cli\u003eTitle 2 by Robert de Niro\u003c/li\u003e\u003c/ul\u003e'\n```\n\nIdeally you don't want to have to put the template in every time so you can add default\ntemplates based on the object key.\n\n```js\n$.fumanchu.templates.items = '\u003cli\u003e{{title}} by {{author}}\u003c/li\u003e';\n```\n\n### Functions\n\nFunctions can be used as helpers and should typically return a string. The arguments passed\nto the function are the objects that were passed to `$.fumanchu()`.\n\n```js\nvar output = $.fumanchu( '{{titlehelper}}', {\n  titlehelper: function( context ) {\n    if ( context.showauthor )\n      return '{{title}} by {{author}}'\n\telse\n\t  return '{{title}}'\n  },\n  showauthor: true,\n  title: 'Some title'\n  author: 'Robert O\\'Rourke'\n} );\n// output = 'Some title by Robert O\\'Rourke'\n```\n\n## Priming the templates object\n\nFumanchu will search the document for elements with the data attribute `data-template`. The\ncontent of those elements will be stored as templates for use by arrays, or accessible in\nfunctions through the global namespace.\n\n```html\n\u003cscript type=\"text/x-fumanchu\" data-template=\"items\"\u003e\n  \u003cli\u003e{{title}} by {{author}}\u003c/li\u003e\n\u003c/script\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froborourke%2Ffumanchu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froborourke%2Ffumanchu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froborourke%2Ffumanchu/lists"}