{"id":22505661,"url":"https://github.com/mageddo/mustache-layout","last_synced_at":"2025-03-27T23:26:52.739Z","repository":{"id":57148398,"uuid":"43652778","full_name":"mageddo/mustache-layout","owner":"mageddo","description":"A mustache template engine with layout architecture","archived":false,"fork":false,"pushed_at":"2016-12-05T14:12:45.000Z","size":25,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-04T06:47:55.978Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mageddo.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-10-04T21:06:13.000Z","updated_at":"2016-12-03T11:50:13.000Z","dependencies_parsed_at":"2022-08-31T20:02:15.681Z","dependency_job_id":null,"html_url":"https://github.com/mageddo/mustache-layout","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mageddo%2Fmustache-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mageddo%2Fmustache-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mageddo%2Fmustache-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mageddo%2Fmustache-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mageddo","download_url":"https://codeload.github.com/mageddo/mustache-layout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245940461,"owners_count":20697402,"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-12-07T00:30:40.052Z","updated_at":"2025-03-27T23:26:52.715Z","avatar_url":"https://github.com/mageddo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mustache-layout\nA mustache template engine with layout architecture\n\n# Features\n\n* All [Mustache ](http://mustache.github.io) features like\n\t* Partials\n\t* Fors\n\t* Functions \n* Express 3.x/4.x support\n\n# A Simple example\n\nLooping cart product items\n\ncart-items.html\n\n\t\u003cul\u003e\n\t{{#cartItems}}\n\t\t\u003cli\u003e{{name}} - {{price}}\u003c/li\u003e\n\t{{/cartItems}}\n\t\u003c/ul\u003e\n\ncontroller.js\n\n\tapp.get(\"/cart\", function(req, res) {\n\t\tres.render(\"cartItems\", {\n\t\t\tcartItems: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Tommy Hilfiger\",\n\t\t\t\t\tdescription: \"Combining contrast brand name printed on the front ...\",\n\t\t\t\t\tprice: 9.98,\n\t\t\t\t\tquantity: 3\n\t\t\t\t},{\n\t\t\t\t\tname: \"TOPMAN\",\n\t\t\t\t\tdescription: \"Classic fit\",\n\t\t\t\t\tprice: 15.98,\n\t\t\t\t\tquantity: 5\n\t\t\t\t}\n\t\t\t],\n\t\t});\n\t});\n\n\n# Other samples\n* Visit demo folder and run the express sample `npm install \u0026\u0026 npm start` then visit [the demo](http://localhost:3003)\n*\t[Download the project demo](https://github.com/mageddo/mustache-layout-demo)\n\n* creating your own demo\n\n\t```javascript\n\tvar app = require(\"express\");\n\t// here express configurations\n\t...\n\tvar mustacheLayout = require(\"mustache-layout\");\n\t\n\tapp.locals({\n\t\t\"title\": \"Demo mustache layout with express\"\n\t});\n\t\n\tapp.set('views', './view');\n\tapp.set('view engine', 'html');\n\tapp.set(\"view options\", {layout: true});\n\tapp.engine(\"html\", mustacheLayout);\n\n\tapp.get(\"/withCustomLayout\", function(req, res) {\n\t\tres.render(\"myView\", {\n\t\t\taVariable: \"helloWorld\",\n\t\t\tlayout: \"myCustomLayout\"\n\t\t});\n\t});\n\tapp.get(\"/withoutLayout\", function(req, res) {\n\t\tres.render(\"myView\", {\n\t\t\taVariable: \"helloWorld\",\n\t\t\tlayout: false\n\t\t});\n\t});\n\tapp.get(\"/withDefaultLayout\", function(req, res) {\n\t\tres.render(\"myView\", {\n\t\t\taVariable: \"helloWorld\"\n\t\t});\n\t});\n\t```\n\n# Escaping template tags\nOn versions `1.0.6` and bellow, all the mustache templates are compiled on serverside, it means that if you have a \ntemplate tag inside `.html` it will be compiled, now it not occurs\n\n## Observations\n* Make sure that every template have a id, or unique attribute to be different of others templates\n\t* wrong examples\n\n\t\t\t\u003cscript type=\"text/template\" class=\"xyz\"\u003e\u003c/script\u003e\n\t\t\t\u003cscript type=\"text/template\" class=\"xyz\"\u003e\u003c/script\u003e\n\n\t* right examples\n\n\t\t\t\u003cscript type=\"text/template\" class=\"xyz\"\u003e\u003c/script\u003e\n\t\t\t\u003cscript type=\"text/template\" class=\"xyz2\"\u003e\u003c/script\u003e\n\n* Ever, use `type=\"text/template\"`\n\n\n## If for some motive you want to do not it, on `view options` set `escapeTemplate` to `false`\n\n# License\n\nThis project is released under version 2.0 of the [Apache License][].\n[Apache License]: http://www.apache.org/licenses/LICENSE-2.0\n\n**Please** say me if it works for you contacting `edigitalb@gmail.com` or [creating suggestions and defects](https://github.com/mageddo/mustache-layout/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmageddo%2Fmustache-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmageddo%2Fmustache-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmageddo%2Fmustache-layout/lists"}