{"id":37085530,"url":"https://github.com/cesbit/trender","last_synced_at":"2026-01-14T10:31:13.972Z","repository":{"id":62585235,"uuid":"44837764","full_name":"cesbit/trender","owner":"cesbit","description":"Template Render Engine","archived":false,"fork":false,"pushed_at":"2024-06-05T07:52:23.000Z","size":113,"stargazers_count":21,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-29T08:58:01.074Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/cesbit.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-23T20:49:55.000Z","updated_at":"2024-07-26T14:05:21.000Z","dependencies_parsed_at":"2022-11-03T21:48:49.549Z","dependency_job_id":null,"html_url":"https://github.com/cesbit/trender","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/cesbit/trender","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesbit%2Ftrender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesbit%2Ftrender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesbit%2Ftrender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesbit%2Ftrender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cesbit","download_url":"https://codeload.github.com/cesbit/trender/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesbit%2Ftrender/sbom","scorecard":{"id":271509,"data":{"date":"2025-08-11","repo":{"name":"github.com/cesbit/trender","commit":"705810c20415e2b97edef6d626c074ba5ae7d5a3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 1/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/cesbit/trender/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/cesbit/trender/ci.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:21","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:22","Warn: pipCommand not pinned by hash: .github/workflows/ci.yml:23","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T13:30:21.732Z","repository_id":62585235,"created_at":"2025-08-17T13:30:21.732Z","updated_at":"2025-08-17T13:30:21.732Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28417403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:25:19.714Z","status":"ssl_error","status_checked_at":"2026-01-14T10:22:49.371Z","response_time":107,"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":[],"created_at":"2026-01-14T10:31:13.903Z","updated_at":"2026-01-14T10:31:13.961Z","avatar_url":"https://github.com/cesbit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/cesbit/trender/workflows/CI/badge.svg)](https://github.com/cesbit/trender/actions)\n[![Release Version](https://img.shields.io/github/release/cesbit/trender)](https://github.com/cesbit/trender/releases)\n\nTemplate Render Engine\n======================\n\nWhy TRender?\n------------\nIt is just another template render engine written in native Python.\n\nInstallation\n------------\nThe easiest way is to use PyPI:\n\n    sudo pip3 install trender\n\nQuick usage\n-----------\n```python\nfrom trender import TRender\n\ntemplate = '@greet world!'\ncompiled = TRender(template)\noutput = compiled.render({'greet': 'Hello'})\n\nprint(output) # =\u003e Hello world!\n```\n\nBasics\n------\nTRender uses a template as input. This template can be a string or filename. Some options like `include` and `extend` are only available when using a filename and template path. When initializing an instance of TRender it will compile the given template. Usually this will happen only once for each template. The TRender instance can then be rendered with a dictionary (we call this a namespace and we actually create a 'Namespace' instance from the given dictionary). TRender is optimized to render a compiled template very fast.\n\nWhen using a filename we also need to specify a path, like:\n```python\nTRender('base.template', path='path_to_file')\n```\n\nNote that `path` should be the root path for your templates. Assume we have the following path structure:\n\n\t/templates/\n\t/templates/pages/\n\t\t\tbase.template\n\t/templates/components/\n\t\t\tcomponent.template\n\nThen it is best to initialize TRender like `TRender('pages/base.template', '/templates')` so the engine will be\nable to find `components/component.template` when used inside your template.\n\nBoth `#extend` and `#include` are only available when using a template file, not with a simple string.\n\nUsing variable\n--------------\nVariable in a template are prefixed with an `@` and optionally can be closed with an `!` exclamation mark. A variable can only include alphabetic characters, digits and underscores. (And a `.`, but this has a special meaning to select nested variable). If you want to use a `@` as a symbol in the template, add `!` as an escape character.\n\nExamples:\n```python\n# Just render a simple variable...\n\nTRender('@name is sweet').render({\n\t'name': 'Iris'\n})\n# Output =\u003e \"Iris is sweet\"\n```\n\n```python\n# Escape @ to render an email address...\n\nTRender('@name@!@domain').render({\n\t'name': 'iris',\n\t'domain': 'home.nl'\n})\n# Output =\u003e \"iris@home.nl\"\n```\n\n```python\n# Use nested variable (you can use nesting as deep as you want)...\n\nTRender('@person.name is @person.age years old').render({\n\t'person': {\n\t\t'name': 'Iris',\n\t\t'age': 4\n\t}\n})\n# Output =\u003e \"Iris is 4 years old\"\n```\n\n```python\n# Close variable when needed...\n\nTRender('@name!IsSweet').render({\n\t'name': 'Iris'\n})\n# Output =\u003e \"IrisIsSweet\"\n```\n\nComments\n--------\nComments should start with `##` or a `#` followed by a `space`.\n\nExample:\n```\n# This is a comment line\n##This is a comment line too\n```\n\nConditionals\n------------\nConditionals are very simple in TRender. We evaluate a simple value or allow a function for more complex conditionals.\nWe start with `#if` followed by an optional `#elif` finally an optional `#else` and close with `#end`.\nIf a conditional is not available in the namespace it will evaluate as `false`.\n\nSimple example:\n```python\nTRender('''\n\n#if @sweet:\n\tI'm sweet\n#elif @nice:\n\tI'm nice\n#else:\n\tDon't know..\n#end\n\n''').render({'nice': True})\n\n# Output =\u003e \"I'm nice\"\n```\n\nComplex example (actually it's not really complex...)\n```python\nTRender('''\n\n#if @old_enough(@person.age):\n\tI'm old enough\n#else:\n\tI'm NOT old enough\n#end\n\n''').render({\n\t'old_enough': lambda age: age \u003e= 18,\n\t'person': {'age': 37}\n})\n\n# Output =\u003e \"I'm old enough\"\n```\n\nLoops\n-----\nWe use `#for` loops and the loop should always close with `#end`.\n\nSince an example explains more than words:\n```python\nTRender('''\n\n#for @person in @people:\n\t@person.name is @person.age years old\n#end\n\n''').render({\n\t'people': [\n\t\t{'name': 'Iris', 'age': 4},\n\t\t{'name': 'Sasha', 'age': 32}\n\t]\n})\n\n# Output =\u003e\n#\tIris is 4 years old\n#\tSasha is 32 years old\n```\n\nBlocks\n------\nSometimes you want to define a block and re-use this block several times. As a name convention I like to write blocks using CamelCase.\n\nExample:\n```python\nTRender('''\n\n#block Item:\n    \u003cli\u003e@item\u003c/li\u003e\n#end\n\n\u003cul\u003e\n#for @item in @items:\n    #Item\n#end\n\u003c/ul\u003e\n\n''').render({\n    'items': ['laptop', 'mouse']\n})\n\n# Output =\u003e\n#    \u003cul\u003e\n#        \u003cli\u003elaptop\u003c/li\u003e\n#        \u003cli\u003emouse\u003c/li\u003e\n#    \u003c/ul\u003e\n```\n\nMacros\n------\nMacros are like blocks, except that they will be compiled only once using the namespace where the macro is defined. For example if we had used a `macro` in the `block` example above, we would get two empty `\u003cli\u003e\u003c/li\u003e` items since `@item` was not available when defining the macro. As a name convention I like to write macros using UPPERCASE_CHARACTERS.\n\nInclude\n-------\nIncluding files is only possible when using a template file as source. Includes happen at compile time so they have no extra costs during rendering.\n\nExample:\n```html\n# base.template\n\u003ch1\u003eLet's include a file\u003c/h1\u003e\n#include another.template\n\u003cspan\u003eYes, it worked!\u003c/span\u003e\n```\n```html\n# another.template\n\u003cspan\u003ePlease, include me...\u003c/span\u003e\n```\n```python\n# Now compile and render the templates\nTRender('base.template', '.').render()\n\n# Output =\u003e\n#    \u003ch1\u003eLet's include a file\u003c/h1\u003e\n#    \u003cspan\u003ePlease, include me...\u003c/span\u003e\n#    \u003cspan\u003eYes, it worked!\u003c/span\u003e\n```\n\nExtend\n------\nExtend can be used to extend a template. This is ofter useful when we want to use a `base` template but start rendering another specific template. It's only possible to use extend when using a template file as source.\n\nExample:\n```html\n# base.template\n\u003chtml\u003e\n\u003chead\u003e\n\u003ctitle\u003eI'm a base template\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n#CONTENT\n\u003c/body\u003e\n\u003c/html\u003e\n```\n```html\n# some.template\n#extend base.template:\n\n#macro CONTENT:\n\u003cspan\u003eThis is just some content...\u003c/span\u003e\n#end \u003c!-- End of CONTENT --\u003e\n\n#end \u003c!-- End of extend base.template --\u003e\n```\n```python\n# Now compile and render the templates\nTRender('some.template', '.').render()\n\n# Output =\u003e\n#    \u003chtml\u003e\n#    \u003chead\u003e\n#    \u003ctitle\u003eI'm a base template\u003c/title\u003e\n#    \u003c/head\u003e\n#    \u003cbody\u003e\n#    \u003cspan\u003eThis is just some content...\u003c/span\u003e\n#    \u003c/body\u003e\n#    \u003c/html\u003e\n```\n\nHow to use TRender with aiohttp (web server)\n--------------------------------------------\nTRender can used together with the `aiohttp` web server by using simple decorators for loading and rendering templates.\n\nExample:\n```python\nfrom trender.aiohttp_template import setup_template_loader\nfrom trender.aiohttp_template import template\n\n# The 'template' decorator can be used to load a template.\n# we assume in this example that you have the following template:\n#\n#   /my_template_path/base.template\n#\n# and you want to render this using the namespace:\n#\n#   {'name': 'Iris'}\n\n@template('base.template')\nasync def myhandler(request):\n    return {'name': 'Iris'}\n\n# This will setup the template loader. Make sure you run this only once,\n# after template decorators are initialized.\nsetup_template_loader('/my_template_path')\n\n\n# Thats it!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesbit%2Ftrender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcesbit%2Ftrender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesbit%2Ftrender/lists"}