{"id":31744918,"url":"https://github.com/roadsideseb/lektor-envvars","last_synced_at":"2025-10-09T12:28:06.605Z","repository":{"id":62575569,"uuid":"135837510","full_name":"roadsideseb/lektor-envvars","owner":"roadsideseb","description":"A Lektor plugin making environment variables available in templates.","archived":false,"fork":false,"pushed_at":"2018-06-13T05:31:34.000Z","size":13,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-28T10:26:27.918Z","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/roadsideseb.png","metadata":{"files":{"readme":"README.rst","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}},"created_at":"2018-06-02T17:17:52.000Z","updated_at":"2020-03-25T08:53:37.000Z","dependencies_parsed_at":"2022-11-03T20:43:35.448Z","dependency_job_id":null,"html_url":"https://github.com/roadsideseb/lektor-envvars","commit_stats":null,"previous_names":["elbaschid/lektor-envvars"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/roadsideseb/lektor-envvars","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadsideseb%2Flektor-envvars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadsideseb%2Flektor-envvars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadsideseb%2Flektor-envvars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadsideseb%2Flektor-envvars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roadsideseb","download_url":"https://codeload.github.com/roadsideseb/lektor-envvars/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roadsideseb%2Flektor-envvars/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001445,"owners_count":26083078,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-10-09T12:28:03.967Z","updated_at":"2025-10-09T12:28:06.591Z","avatar_url":"https://github.com/roadsideseb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"lektor-envvars\n##############\n\n.. image:: https://circleci.com/gh/elbaschid/lektor-envvars.svg?style=svg\n    :target: https://circleci.com/gh/elbaschid/lektor-envvars\n\n\nWhy this project?\n-----------------\n\n**TL;DR** You can use environment variables in your Lektor templates.\n\nI've been working with `Lektor \u003chttps://www.getlektor.com/docs/plugins/\u003e`_ as as\nstatic site generator in quite a few projects and really enjoy it. Most recently\nI work on a project that used an environment variable to create slightly\ndifferent version of the site for ``development``, ``staging`` and ``production``.\n\nLektor doesn't have a way to add *environment variables* into the templates, so\nI started building my own little plugin.\n\n\nHow to install it in Lektor\n---------------------------\n\nYou can easily install this plugin following the `Lektor docs\n\u003chttps://www.getlektor.com/docs/plugins/\u003e`_. All you need to do is run::\n\n    $ lektor plugin add lektor-envvars\n\nThis will automatically install the plugin and add it to your project\nconfiguration.\n\n\nUsing environment variables\n---------------------------\n\nYou are able to access environment variables using the ``envvars`` function\ninside your Jinja2 template. This function is added whenever lektor is running\na new build. \n\nAll environment variables are prefixed with ``LEKTOR_`` by default. Let's look\nat a simple example with an environment varialbe ``LEKTOR_DEBUG=true``::\n\n    $ export LEKTOR_DEBUG=true\n\nYou can access this variable inside any Jinja2 template::\n\n    {{ envvars('DEBUG') }}\n\nwhich will display ``true`` instead.\n\n\nConverting values\n-----------------\n\nThat's a great start but what if you want this to be a boolean value instead of\nthe string ``true``? You simply convert the value::\n\n    {{ envvars('DEBUG', bool) }}\n\nor you can now even do::\n\n    {% if envvars('DEBUG', bool) %}\n        ...\n    {% endif %}\n\n\nCustom prefixes (or no prefix)\n------------------------------\n\nIf you don't like the ``LEKTOR_`` prefix, you can either use your own prefix by\nsetting the prefix in the ``configs/lektor-envvars.ini`` file::\n\n    [envvars]\n    prefix = MY_OWN_\n\nYou can now use ``MY_OWN_DEBUG`` instead of ``LEKTOR_DEBUG``. This means that\nall environment variables need to be prefixed with ``MY_OWN_`` now instead.\n\nYou can also ignore the prefix all together::\n\n    {{ envvars('DEBUG', no_prefix=True) }}\n\nwhich will give you access to the environment variable ``DEBUG``.\n\n\nLicense\n-------\n\nThis code is licensed under the `MIT License`_.\n\n.. _`MIT License`: https://github.com/elbaschid/lektor-envvars/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froadsideseb%2Flektor-envvars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froadsideseb%2Flektor-envvars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froadsideseb%2Flektor-envvars/lists"}