{"id":42212916,"url":"https://github.com/foliant-docs/foliantcontrib.templateparser","last_synced_at":"2026-01-27T01:06:55.416Z","repository":{"id":57431756,"uuid":"186622130","full_name":"foliant-docs/foliantcontrib.templateparser","owner":"foliant-docs","description":null,"archived":false,"fork":false,"pushed_at":"2021-07-20T11:34:29.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-28T00:22:59.956Z","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/foliant-docs.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-14T12:55:29.000Z","updated_at":"2021-07-20T11:34:01.000Z","dependencies_parsed_at":"2022-09-02T12:40:09.784Z","dependency_job_id":null,"html_url":"https://github.com/foliant-docs/foliantcontrib.templateparser","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/foliant-docs/foliantcontrib.templateparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.templateparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.templateparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.templateparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.templateparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foliant-docs","download_url":"https://codeload.github.com/foliant-docs/foliantcontrib.templateparser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.templateparser/sbom","scorecard":{"id":406106,"data":{"date":"2025-08-11","repo":{"name":"github.com/foliant-docs/foliantcontrib.templateparser","commit":"327559bc8a894636d078b1e3aa19ccbb1ab272b3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/14 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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":"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":"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:0","Info: FSF or OSI recognized license: MIT License: LICENSE: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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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"}}]},"last_synced_at":"2025-08-18T21:17:58.261Z","repository_id":57431756,"created_at":"2025-08-18T21:17:58.261Z","updated_at":"2025-08-18T21:17:58.261Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28794642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T21:49:50.245Z","status":"ssl_error","status_checked_at":"2026-01-26T21:48:29.455Z","response_time":59,"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-27T01:06:54.360Z","updated_at":"2026-01-27T01:06:55.387Z","avatar_url":"https://github.com/foliant-docs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://img.shields.io/pypi/v/foliantcontrib.templateparser.svg)](https://pypi.org/project/foliantcontrib.templateparser/)  [![](https://img.shields.io/github/v/tag/foliant-docs/foliantcontrib.templateparser.svg?label=GitHub)](https://github.com/foliant-docs/foliantcontrib.templateparser)\n\n# TemplateParser preprocessor for Foliant\n\nPreprocessor which allows to use templates in Foliant source files. Preprocessor now supports only [Jinja2](http://jinja.pocoo.org/) templating engine, but more can be added easily.\n\n## Installation\n\n```bash\n$ pip install foliantcontrib.templateparser\n```\n\n## Config\n\nAll params that are stated in foliant.yml are considered global params. All of them may be overriden in template tag options, which have higher priority.\n\n```yaml\npreprocessors:\n    - templateparser:\n        engine: jinja2\n        engine_params:\n            root: '/usr/src/app'\n        context:\n            param1: 1008\n            param2: 'Kittens'\n        ext_context: context.yml\n        param3: 'Puppies'\n```\n\n`engine`\n:   name of the template engine which will be used to process template. Supported engines right now: `jinja2`.\n\n`engine_params`\n:   dictionary with parameters which will be transfered to the template engine.\n\n`context`\n:   dictionary with variables which will be redirected to the template.\n\n`ext_context`\n:   path to YAML- or JSON-file with context dictionary. (relative to current md-file), or URL to such file on the remote server.\n\n_All parameters with other names are also transfered to the template, as if they appeared inside the `context` dictionary. (`param3` in the above example)_\n\n\u003e Please note that even if this may seem convenient, it is preferred to include template variables in the `context` dictionary, as in future more reserved parameters may be added which may conflict with your stray variables.\n\nIf some variable names overlap among these methods to supply context, preprocessor uses this priority order:\n\n1. Context dictionary.\n2. Stray variables.\n3. External context file.\n\n## Usage\n\nTo use the template in a Markdown file just insert a tag of the template engine name, for example:\n\n```html\nThis is ordinary markdown text.\n\u003cjinja2\u003e\nThis is a Jinja2 template:\nI can count to five!\n{% for i in range(5) %}{{ i + 1 }}{% endfor %}\n\u003c/jinja2\u003e\n```\n\nAfter making a document with Foliant this will be transformed to:\n\n```\nThis is ordinary markdown text.\n\nThis is a Jinja2 template:\nI can count to five!\n12345\n```\n\nYou can also use a general `\u003ctemplate\u003e` tag, but in this case you have to specify the engine you want to use in the `engine` parameter:\n\n```html\nThis is ordinary markdown text.\n\u003ctemplate engine=\"jinja2\"\u003e\nThis is a Jinja2 template:\nI can count to five!\n{% for i in range(5) %}{{ i + 1 }}{% endfor %}\n\u003c/template\u003e\n```\n\n### Sending variables to template\n\nTo send a variable to template, add them into the `context` option. This option accepts `yaml` dictionary format.\n\n```html\n\u003cjinja2 context=\"{'name': Andy, 'age': 8}\"\u003e\nHi, my name is {{name}}!\nI am {{ age }} years old.\n{% for prev in range(age - 1, 0, -1) %}\nThe year before I was {{prev}} years old.\n{% endfor %}\n\u003c/jinja2\u003e\n```\n\nResult:\n\n```\nHi, my name is Andy!\nI am 8 years old.\n\nThe year before I was 7 years old.\n\nThe year before I was 6 years old.\n\nThe year before I was 5 years old.\n\nThe year before I was 4 years old.\n\nThe year before I was 3 years old.\n\nThe year before I was 2 years old.\n\nThe year before I was 1 years old.\n```\n\nAlso, you can supply a yaml-file with variables in an `ext_context` parameter:\n\n```\n\u003cjinja2 ext_context=\"swagger.yaml\"\u003e\nSwagger file version: {{ swagger }}\nBase path: {{ base_path }}\n...\n\u003c/jinja2\u003e\n```\n\n### Built-in variables\n\nThere are some variables that are available in your template by default:\n\n- `_foliant_context` — dictionary with all user-defined variables, from tag parameters, `context` or `ext_context` variables,\n- `_foliant_vars` — dictionary with all variables mentioned below (in case of name collisions),\n- `meta` — dictionary with current chapter's metadata, details in the next chapter,\n- `meta_object` — project's meta object, details in the next chapter,\n- `config` — Foliant project config,\n- `target` — current target,\n- `backend` — current backend.\n\n### Integration with metadata\n\nTemplates support latest Foliant [metadata](https://foliant-docs.github.io/docs/cli/meta/) functionality. You can find the meta dictionary for current section under `meta` variable inside template:\n\n```html\n\u003cmeta status=\"ready\" title=\"Custom Title\" author=\"John\"\u003e\u003c/meta\u003e\n\n\u003cjinja2\u003e\nDocument status: {{ meta.status }}\n\nThe document \"{{ meta.title }}\" is brought to you by {{ meta.author }}\n\u003c/jinja2\u003e\n```\n\nResult:\n\n```html\nDocument status: ready\n\nThe document \"Custom Title\" is brought to you by John\n```\n\nYou can also find the whole project's `Meta` object under `meta_object` variable inside template:\n\n```html\n\u003cmeta status=\"ready\" title=\"Custom Title\" author=\"John\"\u003e\u003c/meta\u003e\n\n\u003cjinja2\u003e\nList of chapters in this project:\n{% for chapter in meta_object.chapters %}\n* {{ chapter.name }}\n{%- endfor %}\n\u003c/jinja2\u003e\n```\n\nResult:\n\n```html\nList of chapters in this project:\n\n* index\n* sub\n* auth\n```\n\n### Extends and includes\n\nExtends and includes work in templates. The path of the extending\\\\included file is relative to the Markdown file where the template lives.\n\nIn Jinja2 engine you can override the path of the included\\\\extended files with `root` engine_param. **Note that this param is relative to project root.**\n\n### Pro tips\n\n**Pro tip #1**\n\nAll context variables are also available in the `_foliant_context` dictionary. It may be handy if you don't know at design-time which key names are supplied in the external context file:\n\n```\n\u003cjinja2 ext_context=\"customers.yml\"\u003e\n{% for name, data in _foliant_context.items() %}\n\n# Customer {{ name }}\n\nPurchase: {{ data['purchase'] }}\nOrder id: {{ data['order_id'] }}\n\n{% endfor %}\n\u003c/jinja2\u003e\n```\n\n**Pro tip #2**\n\nIf your context file is inside private git repository, you can utilize the power of [Includes](https://foliant-docs.github.io/docs/preprocessors/includes/) preprocessor to retrieve it.\n\n1. Create a file in your `src` dir, for example, `context.md` (`md` extension is obligatory, includes only process markdown files).\n2. Add an includes tag:\n\n**\u0026lt;include repo_url=\"https://my_login:my_password@my.git.org/my_repo.git\" path=\"path/to/file.yml\"\u003e\u003c/include\u003e**\n\n3. And supply path to this file in your `ext_context` param:\n\n```\n\u003cjinja2 ext_context=\"context.md\"\u003e\n```\n\n**Pro tip #3**\n\nIf data inside your external context file is not a dictionary, it will be available inside template under `context` variable (or `_foliant_context['context']`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoliant-docs%2Ffoliantcontrib.templateparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoliant-docs%2Ffoliantcontrib.templateparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoliant-docs%2Ffoliantcontrib.templateparser/lists"}