{"id":13858131,"url":"https://github.com/edwindj/whisker","last_synced_at":"2025-05-14T07:41:35.454Z","repository":{"id":695303,"uuid":"2117834","full_name":"edwindj/whisker","owner":"edwindj","description":"{{mustache}} for R","archived":false,"fork":false,"pushed_at":"2022-11-09T16:27:03.000Z","size":152,"stargazers_count":209,"open_issues_count":19,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-21T02:53:32.961Z","etag":null,"topics":["mustache-templates","r"],"latest_commit_sha":null,"homepage":"https://mustache.github.io","language":"R","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/edwindj.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":"2011-07-28T10:01:34.000Z","updated_at":"2024-03-30T09:37:57.000Z","dependencies_parsed_at":"2023-01-13T10:36:59.630Z","dependency_job_id":null,"html_url":"https://github.com/edwindj/whisker","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/edwindj%2Fwhisker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwindj%2Fwhisker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwindj%2Fwhisker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwindj%2Fwhisker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edwindj","download_url":"https://codeload.github.com/edwindj/whisker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225929789,"owners_count":17547039,"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":["mustache-templates","r"],"created_at":"2024-08-05T03:01:57.688Z","updated_at":"2024-11-22T16:30:40.749Z","avatar_url":"https://github.com/edwindj.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"![version](http://www.r-pkg.org/badges/version/whisker)\n![downloads](http://cranlogs.r-pkg.org/badges/whisker)\n[![R build status](https://github.com/edwindj/whisker/workflows/R-CMD-check/badge.svg)](https://github.com/edwindj/whisker/actions)\n[![Build status](https://ci.appveyor.com/api/projects/status/p8t4sin18l54h72d?svg=true)](https://ci.appveyor.com/project/edwindj/whisker)\n[![status](https://tinyverse.netlify.com/badge/whisker)](https://CRAN.R-project.org/package=whisker)\n\n\nWhisker\n=======\n\nWhisker is a [{{Mustache}}](http://mustache.github.com) implementation in \n[R](http://www.r-project.org/) confirming to the Mustache specification.\nMustache is a logicless templating language, meaning that no programming source\ncode can be used in your templates. This may seem very limited, but Mustache is \nnonetheless powerful and has the advantage of being able to be used unaltered in \nmany programming languages. It makes it very easy to write a web application in R \nusing Mustache templates which could also be re-used for client-side rendering with\n\"Mustache.js\".\n\nMustache (and therefore whisker) takes a simple, but different, approach to\ntemplating compared to most templating engines. Most templating libraries, \nsuch as `Sweave`, `knitr` and `brew`, allow the user to mix programming code and text \nthroughout the template. This is powerful, but ties your template directly\nto a programming language and makes it difficult to seperate programming code from \ntemplating code.\n\nWhisker, on the other hand, takes a Mustache template and uses the variables of the \ncurrent `environment` (or the supplied `list`) to fill in the variables.\n\nMustache syntax\n---------------\n\nThe syntax of Mustache templates is described in https://mustache.github.io/mustache.5.html \nHow the mustache template are used with whisker can be found in the whisker documentation, and below.\n\nMustache specification\n----------------------\nWhisker conforms to the [Mustache 1.1 specificaton](https://github.com/mustache/spec) except for delimiter switching and\nlambdas. We expect that these will be implented shortly.\n\nInstallation\n============\n\nTo install whisker use the following statement in your R console\n\n```S\ninstall.packages(\"whisker\")\n```\n\nThe latest whisker version is not yet available on CRAN, but can be installed from github:\n\n```S\nlibrary(devtools)\n\n# dev_mode()\ninstall_github(\"whisker\", \"edwindj\")\n```\n\nUsage\n-----\n\n`whisker.render` accepts a `character` template and a list or environment containing data to render:\n\n\n```S\nlibrary(whisker)\ntemplate \u003c- \n'Hello {{name}}\nYou have just won ${{value}}!\n{{#in_ca}}\nWell, ${{taxed_value}}, after taxes.\n{{/in_ca}}\n'\n\ndata \u003c- list( name = \"Chris\"\n            , value = 10000\n            , taxed_value = 10000 - (10000 * 0.4)\n            , in_ca = TRUE\n            )\n\ntext \u003c- whisker.render(template, data)\ncat(text)\n```\n\n```\n## Hello Chris\n## You have just won $10000!\n## Well, $6000, after taxes.\n```\n\n\nOr using a text file\n\n\n```S\nlibrary(whisker)\n\ntemplate \u003c- readLines(\"./template.html\")\ndata \u003c- list( name = \"Chris\"\n            , value = 10000\n            , taxed_value = 10000 - (10000 * 0.4)\n            , in_ca = TRUE\n            )\n\nwriteLines(whisker.render(template, data), \"./output.html\")\n```\n\n\nNote\n----\n\nBy default `whisker` applies `html` escaping on the generated text.\nTo prevent this use `{{{variable}}}` (triple) in stead of `{{variable}}`.\n\n\n```S\ntemplate \u003c- \n\"I'm escaped: {{name}}\nAnd I'm not: {{{name}}}\"\n\ndata \u003c- list( name = '\u003cMy Name=\"Nescio\"\u003e')\nwhisker.render(template, data)\n```\n\nGenerates:\n```\nI'm escaped: \u0026lt;My Name=\u0026quot;Nescio\u0026quot;\u0026gt;\nAnd I'm not: \u003cMy Name=\"Nescio\"\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwindj%2Fwhisker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedwindj%2Fwhisker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwindj%2Fwhisker/lists"}