{"id":22940773,"url":"https://github.com/inductivecomputerscience/pbtpl","last_synced_at":"2025-06-21T06:06:13.492Z","repository":{"id":144579182,"uuid":"500541669","full_name":"InductiveComputerScience/pbTpl","owner":"InductiveComputerScience","description":"Easy to use Template Library Available in Many Programming Languages","archived":false,"fork":false,"pushed_at":"2022-06-10T06:55:19.000Z","size":280,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T20:36:41.738Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/InductiveComputerScience.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":"2022-06-06T18:05:07.000Z","updated_at":"2022-06-06T21:20:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"09a3bda7-64a6-45e5-af84-2b906da77f99","html_url":"https://github.com/InductiveComputerScience/pbTpl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/InductiveComputerScience/pbTpl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InductiveComputerScience%2FpbTpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InductiveComputerScience%2FpbTpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InductiveComputerScience%2FpbTpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InductiveComputerScience%2FpbTpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InductiveComputerScience","download_url":"https://codeload.github.com/InductiveComputerScience/pbTpl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InductiveComputerScience%2FpbTpl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261073375,"owners_count":23105642,"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-14T13:30:58.726Z","updated_at":"2025-06-21T06:06:08.477Z","avatar_url":"https://github.com/InductiveComputerScience.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pbTpl - pb Templates\nA template library available in many programming languages made with [progsbase](https://progsbase.com/). The goals of this library are to \n\n1) Have a single library for templating that is stable accross programming languages and over time.\n2) Is easy to build in any programming language and to include in any project.\n3) Is easy to use.\n\n\n## Try Online\nTry the library [online here](https://repo.progsbase.com/repoviewer/no.inductive.libraries/TextualTemplates/0.1.10///GenerateDocument/).\n\n\n\n## Available in the Following Languages\n\n * [TypeScript](TypeScript/)\n * [Java](Java/)\n * [C](C/)\n * [C++](Cpp/)\n * [JavaScript](JavaScript/)\n * [PHP](PHP/)\n * [C#](CS/)\n * [Python](Python/)\n * [Ruby](Ruby/)\n * [Visual Basic](VisualBasic/)\n\n## Main Function\nThe library is available in the programming languages above. The main function for using a template is as follows:\n\n```\nTypeScript:\nfunction GenerateDocument(template : string [], json : string [], document : StringReference, errorMessage : StringReference) : boolean\n\nJava:\nboolean GenerateDocument(char [] template, char [] json, StringReference document, StringReference errorMessage)\n\nC:\n_Bool GenerateDocument(wchar_t *template, size_t templateLength, wchar_t *json, size_t jsonLength, StringReference *document, StringReference *errorMessage)\n\nC++:\nbool GenerateDocument(vector\u003cwchar_t\u003e *templatex, vector\u003cwchar_t\u003e *json, StringReference *document, StringReference *errorMessage)\n\nJavaScript:\nfunction GenerateDocument(template, json, document, errorMessage)\n\nPHP:\nfunction GenerateDocument(\u0026$template, \u0026$json, $document, $errorMessage)\n\nC#:\nbool GenerateDocument(char [] template, char [] json, StringReference document, StringReference errorMessage)\n\nPython:\ndef GenerateDocument(template, json, document, errorMessage)\n\nRuby:\ndef GenerateDocument(template, json, document, errorMessage)\n\nVisual Basic:\nFunction GenerateDocument(ByRef template As Char (), ByRef json As Char (), ByRef document As StringReference, ByRef errorMessage As StringReference) As Boolean\n```\n\nThis function works exactly the same way in all the languages. It takes a template string `template` and JSON string `json`. It returns true on success or false on failure. On success, `document.string` is set to the result; on failure `errorMessage.string` is filled with an error message.\n\n\n## General About Templates\nA textual template is text with certain parts left out that will be filled in by a generation step. The source for filling in is a data structure generated from a JSON file.\n\nTemplates are used for many different things in production systems. Most websites are generated based on a template, be it directly in the front end, such as with Angular, React and Vue, or in the backend. Templates are also used for production of formal documents and emails.\n\n\n## Tags and Their Functions\n\n### Print Value\n```\n{print a}\n```\n\nWill print the value of a. If it is a JSON object or structure, the JSON repressentation will be printed.\n \n### Use structure\n```\n{use a}\n{print b}\n{end}\n```\n\nThis will cause a.b to be printed. Inside the use structure, the variables inside structure a can be used.\n\n### Iterate\n```\n{foreach a in b}\n{end}\n```\n\nThis will iterate over all elements of the array `b`. Each element will be known as `a` inside. If `a` is an object, it will automatically be used inside the foreach loop, so there is no need to write `{use a}`.\n\n### If-else\n```\n{if a}\n{else}\n{end}\n```\n\nIf a is true, the first block is printed, else the else block. The else block is optional.\n\n### Escape\nIf you want to output `{` followed directly by one of the command strings, use a backslash in front. If the `{` is not followed directly by one of the commands, the text is simply output.\n\n\n\n## How to Work with Templates\nThere are three main issues with using templates:\n\n### The data model\nGenerate all the data that is to be filled into the document. This includes decision variables if some information is included or left out based on conditions.\n\n### Templates\nWrite the template with the tags to fill in information. There is no need for complex logic or formatting commands, as this should be taken care of during data model generation. The reason is that the code should be in the code and not in the template.\n\n### Locale and Formatting\nSpecial formatting of numbers should be taken care of during data model generation. This is better as a full fledged programming language is available.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finductivecomputerscience%2Fpbtpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finductivecomputerscience%2Fpbtpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finductivecomputerscience%2Fpbtpl/lists"}