{"id":18552448,"url":"https://github.com/andrejewski/stachedown","last_synced_at":"2025-07-27T14:40:36.679Z","repository":{"id":19968163,"uuid":"23235141","full_name":"andrejewski/stachedown","owner":"andrejewski","description":"you got mustache in my markdown","archived":false,"fork":false,"pushed_at":"2014-08-23T22:37:54.000Z","size":144,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T00:02:40.373Z","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":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrejewski.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-08-22T18:19:49.000Z","updated_at":"2021-07-28T11:04:45.000Z","dependencies_parsed_at":"2022-07-25T07:17:01.700Z","dependency_job_id":null,"html_url":"https://github.com/andrejewski/stachedown","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/andrejewski%2Fstachedown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fstachedown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fstachedown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fstachedown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrejewski","download_url":"https://codeload.github.com/andrejewski/stachedown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328389,"owners_count":22052633,"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-06T21:14:14.489Z","updated_at":"2025-05-15T11:13:05.904Z","avatar_url":"https://github.com/andrejewski.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Stachedown\n==========\n\nStachedown renders Mustache templates written in Markdown.\n\n## Installation\n\n```bash\nnpm install stachedown\n```\n\n## Usage\n\nStachedown can be used to `render` HTML from Markdown-Mustache templates and `inject` Mustache directly into Markdown without rendering the Makrdown.\n\n### Rendering HTML\n\n```javascript\nvar Stachedown = require(\"stachedown\"),\n\tstachedown = Stachedown();\n\nvar template = \"{{a}} is *{{b}}*.\",\n\tdata = {a: 'Shrek', b: 'love'};\n\nstachedown.render(template, data);\n// =\u003e \"\u003cp\u003eShrek is \u003cem\u003elove\u003c/em\u003e.\u003c/p\u003e\\n\"\n```\n\n### Injecting Mustache\n\n```javascript\nvar Stachedown = require(\"stachedown\"),\n\tstachedown = Stachedown();\n\nvar template = \"{{a}} is *{{b}}*.\",\n\tdata = {a: 'Shrek', b: 'love'};\n\nstachedown.inject(template, data);\n// =\u003e \"Shrek is *love*.\"\n```\n\n## Configuration\n\nStachedown requires [mustache.js](https://github.com/janl/mustache.js) and [marked](https://github.com/chjj/marked). While it does not provided anything more than functions, Stachedown does expose its dependencies for their own configuration options.\n\n```javascript\nvar Stachedown = require(\"stachedown\"),\n\tMarked = Stachedown.Marked,\n\tMustache = Stachedown.Mustache;\n```\nMarked options can also be passed directly to the Stachedown constructor and will be used for each render with that Stachedown instance. [See marked for more details.](https://github.com/chjj/marked#options-1)\n\n```javascript\nvar Stachedown = require(\"stachedown\"),\n\tstachedown = Stachedown({marked options});\n```\n\nStachedown can determine whether marked is configured asynchronously and adapt to compliment an asynchronous call.\n\n```javascript\nstachedown.render(template, data, function(error, html) {\n\t// Note: This only works for #render().\n\t// Stachedown#inject() is always synchronous.\n});\n```\n\n## Strict Templating\n\nSuppose a template is rendered with an object literal as data using Mustache. Mustache ignores missing and undefined variables in templates.\n\n```javascript\nMustache.render('The {{important_thing}} must be visible.', {});\n// =\u003e 'The  must be visible.'\n```\n\nThis output almost always is not ideal. Stachedown exposes two methods `#renderStrict()` and `#injectStrict()` to ensure variables exist when put into the template.  They have the same function signatures as their `#render()` and `#inject()` counterparts.\n\n```javascript\nstachedown.renderStrict('The {{important_thing}} must be visible.', {});\n// throws Error\n```\n\nWhile strict templating is not a direct goal of Stachedown, I thought the use case was good enough to include it within this module as an option.\n\n## Contributing\n\nContributions are incredibly welcome as long as they are standardly applicable and pass the tests (or break bad ones). Tests are written in Mocha and assertions are done with the Node.js core `assert` module.\n\n```bash\n# running tests\nnpm run test\nnpm run test-spec # spec reporter\n```\n\nFollow me on [Twitter](https://twitter.com/compooter) for updates or just for the lolz and please check out my other [repositories](https://github.com/andrejewski) if I have earned it. I thank you for reading.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejewski%2Fstachedown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrejewski%2Fstachedown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejewski%2Fstachedown/lists"}