{"id":16745373,"url":"https://github.com/aravindavk/tinyview","last_synced_at":"2026-02-11T16:04:08.170Z","repository":{"id":248295611,"uuid":"828307537","full_name":"aravindavk/tinyview","owner":"aravindavk","description":"A small library to support string substitutions and partial includes.","archived":false,"fork":false,"pushed_at":"2024-08-24T18:07:00.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-20T03:07:03.747Z","etag":null,"topics":["d","templates","views"],"latest_commit_sha":null,"homepage":"","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aravindavk.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-13T18:23:29.000Z","updated_at":"2025-01-28T15:11:47.000Z","dependencies_parsed_at":"2024-07-13T19:43:57.419Z","dependency_job_id":"bad802c0-3625-48c5-8284-653b0170df97","html_url":"https://github.com/aravindavk/tinyview","commit_stats":null,"previous_names":["aravindavk/tinyview"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/aravindavk/tinyview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindavk%2Ftinyview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindavk%2Ftinyview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindavk%2Ftinyview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindavk%2Ftinyview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aravindavk","download_url":"https://codeload.github.com/aravindavk/tinyview/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindavk%2Ftinyview/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29337018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T16:00:30.228Z","status":"ssl_error","status_checked_at":"2026-02-11T16:00:25.398Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["d","templates","views"],"created_at":"2024-10-13T01:45:11.543Z","updated_at":"2026-02-11T16:04:08.153Z","avatar_url":"https://github.com/aravindavk.png","language":"D","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tinyview\n\nA small library to support string substitutions and partial includes.\n\nMany use cases doesn't need any complex logic in the templates. Tinyview specially designed for those use cases. For example, to generate static HTML pages or to generate email templates etc.\n\n## Syntax\nSyntax is very easy to remember. Inspired by Liquid and Jinja2, but only variable substitution and partial includes supported.\n\n### Variable substitution\n\n```\n{{ variable_name }}\n```\n\nExample,\n\n```\nDear {{ first_name }},\n\nThank you for the feedback!\n\nRegards\nTinyview\n```\n\n### Include other files\n\n```\n{% include \"filename\" %}\n```\n\nExample,\n\n```\n{% include \"top.html\" %}\n\u003ch1\u003e{{ title }}\u003c/h1\u003e\n\u003cdiv class=\"content\"\u003e\n{{ content }}\n\u003c/div\u003e\n{% include \"footer.html\" %}\n```\n\n## Install\n\nAdd `tinyview` to your project by running the following command.\n\n```\ndub add tinyview\n```\n\n## Hello World!\n\n```d\nimport std.stdio;\n\nimport tinyview;\n\nTinyview view;\n\nvoid main()\n{\n    view = new Tinyview;\n    auto tmpl = \"Hello {{ name }}!\";\n    writeln(view.render(tmpl, [\"name\": \"World\"]));\n    // OR with args\n    auto name = \"World\";\n    auto data = tinyviewDataFromArgs!(name);\n    writeln(view.render(tmpl, data));\n}\n```\n\n```console\n$ dub run\nHello World!\n```\n\n## Usage\n\n### String templates\n\n```d\nauto data = [\n    \"name\": \"Admin\",\n    \"status\": \"Running\"\n];\n\nauto tmpl = q\"[Dear {{ name }},\n\nApplication status is {{ status }}.\n\n]\";\nauto view = new Tinyview;\nwriteln(view.render(tmpl, data));\n```\n\n### String templates with string partials\n\n```d\nTinyviewSettings settings;\nsettings.includes = [\n    \"top.html\": \"\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e\u003ctitle\u003e{{ title }}\u003c/title\u003e\u003c/head\u003e\u003cbody\u003e\",\n    \"footer.html\": \"\u003c/body\u003e\u003c/html\u003e\"\n];\n\nauto data = [\n    \"title\": \"Hello World!\",\n    \"content\": \"Content text\"\n];\n\nauto tmpl = `{% include \"top.html\" %}{{ content }}{% include \"footer.html\" %}`;\nauto view = new Tinyview(settings);\nwriteln(view.render(tmpl, data));\n```\n\n### Render templates from the filesystem\n\nTinyview will look for templates in `settings.viewsDirectory` (Default is `\"./views\"`).\n\n```console\n$ ls views\nindex.html\ntop.html\nseo.html\nfooter.html\n```\n\n```d\nauto data = [\n    \"title\": \"Hello World!\",\n    \"content\": \"Content text\"\n];\n\nauto filename = \"index.html\";\nauto view = new Tinyview;\nwriteln(view.renderFile(filename, data));\n```\n\n### Settings\n\n**viewsDirectory** (Default: `\"./views\"`) - When file name is provided, it will be looked up in this directory.\n\n```d\nsettings.viewsDirectory = \"./\";\n```\n\n**onMissingKey** (Default: `MissingKey.empty`) - By default, render function adds empty string if the variable or include file is not available. Other available options are: \n- `MissingKey.error` to raise error when variable or include file not found. \n- `MissingKey.passThrough` to retain the variable and include syntax as is when not found. Useful for multistage processing.\n\n```d\nsettings.onMissingKey = MissingKey.error;\n```\n\n**maxDepth** (Default: `3`) - If a partial file includes other files and variables, max depth to parse the included template and replace.\n\n```d\nsettings.maxDepth = 2;\n```\n\n**includes** - Partial data to load when called from `{% include \"filename\" %}`\n\n```d\nsettings.includes = [\n    \"top.html\": \"\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e\u003ctitle\u003e{{ title }}\u003c/title\u003e\u003c/head\u003e\u003cbody\u003e\",\n    \"footer.html\": \"\u003c/body\u003e\u003c/html\u003e\"\n];\n```\n\n```d\nTinyviewConfig config;\nsettings.viewsDirectory = \"./\";\nsettings.onMissingKey = MissingKey.error;\nsettings.maxDepth = 2;\nsettings.includes = [\n    \"top.html\": \"\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e\u003ctitle\u003e{{ title }}\u003c/title\u003e\u003c/head\u003e\u003cbody\u003e\",\n    \"footer.html\": \"\u003c/body\u003e\u003c/html\u003e\"\n];\n\nauto view = new Tinyview(settings);\nauto tmpl = \"Hello {{ name }}!\";\nwriteln(view.render(tmpl, [\"name\": \"World\"]));\n```\n\n## Using with the Web frameworks\n\n### With Serverino\n\n```d\nimport serverino;\nimport tinyview;\n\nmixin ServerinoMain;\n\nTinyview view;\n\nstatic this()\n{\n    view = new Tinyview;\n}\n\n@endpoint @route!\"/\"\nvoid homePageHandler(Request request, Output output)\n{\n    auto data = [\n        \"title\": \"Hello World!\"\n    ];\n    output ~= view.renderFile(\"index.html\", data);\n}\n```\n\n### With Vibe.d\n\n```d\nimport vibe.http.server;\nimport vibe.http.router;\nimport vibe.core.core : runApplication;\nimport tinyview;\n\nTinyview view;\n\nstatic this()\n{\n    view = new Tinyview;\n}\n\nvoid homePageHandler(HTTPServerRequest req, HTTPServerResponse res)\n{\n    auto data = [\n        \"title\": \"Hello World!\"\n    ];\n\n    res.writeBody(view.renderFile(\"index.html\", data));\n}\n\nvoid main()\n{\n    auto router = new URLRouter;\n    router.get(\"/\", \u0026homePageHandler);\n\n    auto settings = new HTTPServerSettings;\n\tsettings.port = 8080;\n\tlistenHTTP(settings, router);\n    runApplication;\n}\n```\n\n### With Handy-Httpd\n\n```d\nimport handy_httpd;\nimport handy_httpd.handlers;\nimport tinyview;\n\nTinyview view;\n\nstatic this()\n{\n    view = new Tinyview;\n}\n\nvoid homePageHandler(ref HttpRequestContext ctx)\n{\n    auto data = [\n        \"title\": \"Hello World!\"\n    ];\n\n    ctx.response.writeBodyString(view.renderFile(\"index.html\", data));\n}\n\nvoid main()\n{\n    auto pathHandler = new PathHandler()\n        .addMapping(Method.GET, \"/\", \u0026homePageHandler);\n    new HttpServer(pathHandler).start();\n}\n```\n\n## Contributing\n\n- Fork it (https://github.com/aravindavk/tinyview/fork)\n- Create your feature branch (git checkout -b my-new-feature)\n- Commit your changes (git commit -asm 'Add some feature')\n- Push to the branch (git push origin my-new-feature)\n- Create a new Pull Request\n\n## Contributors\n\n- Aravinda VK - Creator and Maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faravindavk%2Ftinyview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faravindavk%2Ftinyview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faravindavk%2Ftinyview/lists"}