Saravanan666/pypi-org huggingface dataset:
Package: jinja2-registry
jinja2_registryjinja2_registryis a convenience library for managing multiple template namespaces with Jinja2ExampleThe following Python code sets up ajinja2.Environmentand three distinctjinja2.FileSystemLoaderobjects under ajinja2.PrefixLoader. It then renders a HTML page based ontitle.htmlthat includes several other files.fromjinja2_registryimportRenderer,register_filesystem_loaderregister_filesystem_loader('layouts','templates/layouts')register_filesystem_loader('partials','templates/partials')register_filesystem_loader('pages','templates/pages')renderer=Renderer('pages/title.html')html=renderer.render()print(html)The result is rendered from 4 HTML templates, which are located in different directories. In this example, all of the templates are read from the filesystem; however, users may make use ofregister_loaderto attach any standard Jinja2 loader to the registry.Result<!DOCTYPE html><html><head><title>new_title</title></head><body><ul><li><ahref="/content">Content page</a></li><li><ahref="/title">New title page</a></li></ul><div><p>some_content</p></div></body></html>The HTML templates are organized into the following structure. Layouts are separated from partials and content. In a production deployment, layouts would likely be stored separately from pages (e.g., in a library), and partials might be automatically generated.File structure:templates/
├── layouts
│   └── base.html
├── pages
│   ├── content.html
│   └── title.html
└── partials
    └── nav.htmltemplates/layouts/base.html<!DOCTYPE html><html><head><title>{% block title %}default_title{% endblock %}</title></head><body>{% include "partials/nav.html" %}<div>{% block content %}{% endblock %}</div></body></html>templates/partials/nav.html<ul><li><ahref="/content">Content page</a></li><li><ahref="/title">New title page</a></li></ul>templates/pages/content.html{% extends "layouts/base.html" %}
{% block content %}<p>some_content</p>{%- endblock %}templates/pages/title.html{% extends "pages/content.html" %}
{% block title %}new_title{% endblock %}
Package: jinja2rst
Author:Hartmut Goebel <h.goebel@crazy-compilers.com>Copyright:2015 by Hartmut GoebelLicence:GNU General Public Licence v3 or later (GPLv3+)This tool allows you writing documentation directly into jinja2
template-files as comments. These comments will then be converted to
text and the template-code goes into literal blocks.This is some kind ofliterate programming, except that you do not
write code into your text, but text into your code. This difference
allows to use the template-file directly without any pre-processing.Usage:jinja2rst [-h] infile outfile

positional arguments:
  infile      jinja2-template-file to read (`-` for stdin)
  outfile     rst-file to write (`-` for stdout)

optional arguments:
  -h, --help  show this help message and exitHow it worksThis script takes all lines beginning with#(and lines
consisting of only a#) as text-lines. Everything else will be
treated as “code”. The text-lines will get the#removed
and the “code” will get spaces prepended.Additionally at the start and at the end of a “code”-block, lines are
added as required by reStructuredText. Also at the begin of a
“code”-block, a::is added if required.ExamplesYou can find example jinja2-input, rst-output and generated html in the
examples directory. You may also view the generated html online athttps://rawgit.com/htgoebel/jinja2rst/develop/examples/main.html.
Package: jinja2-s3loader
Project Status:Beta. It’s pretty simple and works for me, but not heavily
tested in production use. Caveat Emptor.UsageThis library relies on theboto3library for S3 access, so you will need toconfigure your AWS credentialsfirst. Then, provide your S3 bucket name and
optional template directory name when instantiating the loader:#!python
from jinja2 import Environment
from jinja2_s3loader import S3loader

s3template_dir = "test/templates"  # trailing slash not required, but ok
j2 = Environment(loader=S3loader('my-s3-bucket-name', s3template_dir))
t = j2.get_template('mytemplate.j2')  # loads test/templates/mytemplate.j2
print(t.render({}))Note that, although S3 does not have real directories and treats the prefix
string as purely a sub-string, this S3loader will treat the prefix as a
subdirectory. That is, it will add a trailing slash if none is provided.Remember, accessing files over S3 costs money. The loader currently does not
support live reloading. I built this to support accessing S3 templates from AWS
Lambda functions, so those constraints are fine with me, but your use case may
be different.Contributions welcome. File a Github issue to report a bug.Known IssuesThe loader blindly attempts to decode all templates as UTF-8. If your template
is encoded with an incompatible encoding, it WILL be broken. PR’s welcome.LicenseCopyright 2015 Vince Veselosky and contributors.Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Package: jinja2-sanic
a jinja2 template renderer for Sanic. It supports:function based web handlersclass-based viewsdecoractors for convenient useageYou can find out more here:http://jinja2-sanic.readthedocs.io/en/latest/Installpip3 install jinja2-sanicQuick StartfromsanicimportSanicfromsanic.viewsimportHTTPMethodViewfromsanic.exceptionsimportServerErrorapp=Sanic("sanic_jinja2_render")# Setup jinja2 environmenttemplate="<html><body><h1>{{Player}}</h1>{{Category}}</body></html>"jinja2_sanic.setup(app,loader=jinja2.DictLoader({"templates.jinja2":template}))# Usage in function based web handlers@app.route("/")@jinja2_sanic.template("templates.jinja2")asyncdeffunc(request):return{"Player":"CR7","Category":"Soccer",}# Usage in class-based viewsclassSimpleView(HTTPMethodView):@jinja2_sanic.template("templates.jinja2")asyncdefget(self,request):return{"Player":"CR7","Category":"Soccer",}# register class based view routesapp.add_route(SimpleView.as_view(),"/")# Start Serverif__name__=="__main__":app.run(host="0.0.0.0",port=8000)Developmentjinja2-sanicaccepts contributions on GitHub, in the form of issues or pull requests.Build../uraniumRun unit tests../uranium test
Package: jinja2schema
Demo|Documentation|GitHub|PyPIA library that provides a heuristic type inference algorithm forJinja2templates.>>>fromjinja2schemaimportinfer,to_json_schema>>>s=infer('{{ (x.a.b|first).name }}')>>>s{'x':{'a':{'b':[{'name':<scalar>}]}}>>>s=infer('''
... {% for x in xs %}
...   {{ x }}
... {% endfor %}
''')>>>s{'xs':[<scalar>]}>>>to_json_schema(s){'type':'object','required':['xs'],'properties':{'xs':{'type':'array''title':'xs','items':{'title':'x','anyOf':[{'type':'string'},{'type':'number'},{'type':'boolean'},{'type':'null'}],},}}}More examples can be found at thedemo page.Installingpip install jinja2schemaLicenseBSD license
Package: jinja2-shell
jinja2-shellJinja2 Extension for running shell commands. Makes use ofsubprocess.run(shell=False).InstallationInstall this via pip (or your favourite package manager):pipinstalljinja2-shellUsageThe extension class isjinja2_shell.ShellExtension.If the second argument isTrue(default), the output is stripped of trailing whitespace and newlines. (a\n\b \n->a\nb)As a statement:{% shell "echo Hello World" %}
{% shell "echo Hello World", False %}
{% shell "echo 'Hello World', False %}
{% shell "echo \"Hello World\"", False %}Hello World
Hello World (Ubuntu), Hello World\n (Windows)
Hello World (Ubuntu), Hello World\n (Windows)
Hello World (Ubuntu), Hello World\n (Windows)As a expression:{{ "echo Hello World" | shell }}
{{ "echo Hello World" | shell(False) }}
{{ "echo 'Hello World'" | shell(False) }}
{{ "echo \"Hello World\"" | shell(False) }Hello World
Hello World (Ubuntu), Hello World\n (Windows)
Hello World (Ubuntu), Hello World\n (Windows)
Hello World (Ubuntu), Hello World\n (Windows)Contributors ✨Thanks goes to these wonderful people (emoji key):34j💻🤔📖This project follows theall-contributorsspecification. Contributions of any kind welcome!
Package: jinja2-shell-extension
jinja2_shell_extensionStatus (master branch)What is it ?This is ajinja2extension to execute system/shell
commands from a template.WARNING: be sure to valid any string submitted to this filter as you can
open security holes with itSyntaxThe syntax is'full_command_with_args'|shell([die_on_error_boolean_flag], [encoding]).Examplefromjinja2importTemplate,Environment# We load the extension in a jinja2 Environmentenv=Environment(extensions=["jinja2_shell_extension.ShellExtension"])# For the example, we use a template from a simple stringtemplate=env.from_string("Wed, 19 Jul 2023 11:16:39 +0000")result=template.render()# example: result == "Fri, 31 Jan 2020 13:35:56 +0100"# [...]Contributing guideSeeCONTRIBUTING.mdfile.Code of ConductSeeCODE_OF_CONDUCT.mdfile.Sponsors(If you are officially paid to work on MetWork Framework, please contact us to add your company logo here!)
Package: jinja2-simple-tags
jinja2-simple-tagsjinja2-simple-tagsis a library that provides a simple way to create custom template
tags in Jinja2 templates.Compatibilitypython>= 3.6Jinja2>= 2.10Installationpip install jinja2-simple-tagsUsageTo usejinja2-simple-tags, you need to create a subclass of one of the provided
tag types and implement therendermethod.StandaloneTagStandaloneTagis a tag that doesn't require a closing tag. It can be used like this:fromdatetimeimportdatetimefromjinja2_simple_tagsimportStandaloneTagclassNowExtension(StandaloneTag):tags={"now"}defrender(self,format="%Y-%m-%d%H:%I:%S"):returndatetime.now().strftime(format){% now %}               {# 2023-04-27 20:08:03 #}
{% now '%m/%d/%Y' %}    {# 04/27/2023 #}EscapingBy default, the output ofStandaloneTagwill be escaped. To disable escaping,
set thesafe_outputproperty of your tag toTrue:fromjinja2_simple_tagsimportStandaloneTagclassAlertExtension(StandaloneTag):safe_output=Truetags={"alert"}defrender(self,message):return"<script>alert('{}')</script>".format(message)You can also return ajinja2.Markupobject from therender()method to explicitly
mark the output as safe.ContainerTagContainerTagis a tag that requires a closing tag and can contain arbitrary content.
It can be used like this:importhmacfromjinja2_simple_tagsimportContainerTagclassHMACExtension(ContainerTag):tags={"hmac"}defrender(self,secret,digest="sha256",caller=None):content=str(caller()).encode()ifisinstance(secret,str):secret=secret.encode()signing=hmac.new(secret,content,digestmod=digest)returnsigning.hexdigest(){% hmac 'SECRET', digest='sha1' %}Hello world!{% endhmac %}

{# e29371e24dc99c5641681728855a92e26829e288 #}ContextCurrent context can be accessed usingself.contextattribute of the tag class:fromjinja2_simple_tagsimportStandaloneTagclassUserNameExtension(StandaloneTag):tags={"username"}defrender(self):returnself.context["user"].usernameAssignmentIn addition to returning the rendered value,ContainerTagandStandaloneTagalso supports assigning the output to a variable in the context. This can be done
using theaskeyword:{% now '%m/%d/%Y' as today %}    
...
{{ today }}         {# 04/27/2023 #}{% hmac 'SECRET', digest='sha1' as signature %}Hello world!{% endhmac %}
...
{{ signature }}     {# e29371e24dc99c5641681728855a92e26829e288 #}
Package: jinja2sql
Jinja2SQL (Jinja To SQL)Jinja2SQLis a simple and efficient library for generating SQL queries fromJinja2templates. It is type-friendly and offersasyncsupport, drawing significant inspiration from the excellent library atjinjasql.Documentationhttp://jinja2sql.readthedocs.io/RequirementsPython 3.8+andJinja2 3.1.2+.InstallationInstall usingpip:pipinstalljinja2sqlor usingpoetry:poetryaddjinja2sqlQuick Examplefromjinja2sqlimportJinja2SQLj2sql=Jinja2SQL(param_style="named")# default param style is "named"query,params=j2sql.from_string("SELECT * FROM {{ table | identifier }} WHERE email = {{ email }}",context={"table":"users","email":"user@mail.com"},)# using with your favorite database driver connectionconn.execute(query,params)Param StylesJinja2SQLsupports different param styles depending on the database driver you are using.You can choose between the following supported param styles:fromjinja2sqlimportJinja2SQLj2sql=Jinja2SQL(param_style="named")# defaultquery,params=j2sql.from_string("SELECT * FROM table WHERE param = {{ param }}",context={"param":...},param_style="named",# or "qmark", "numeric", "format", "pyformat", "asyncpg")param_styleExamplenamed:paramqmark?numeric:1format%spyformat%(param)sasyncpg$1or you can provide a custom function to format your database specific param style:fromjinja2sqlimportJinja2SQLj2sql=Jinja2SQL()query,params=j2sql.from_string("SELECT * FROM table WHERE column = {{ param }}",context={"param":...},param_style=lambdakey,_:f"{{{key}}}",)assertquery=="SELECT * FROM table WHERE column ={email}"
Package: jinja2ssg
Jinja2 SSGA very simple static site generator.The filesystem structure in--srcis copied into--dest.Files and folders starting with_are skipped.By default only html, txt, js files are used and the rest of them are skipped.YAML files can be used to provide data inside templates.python3-mpipinstalljinja2ssg
python3-mjinja2ssg--srcsrc--destpublishbuildExamplesite/src/
├── _base.html
├── _social_links.yaml
├── donate
│   └── index.html
├── _footer.html
├── index.html
└── _nav.htmlResults in a DEST structure like:site/www/
├── index.html
└── donate
    └── index.htmlCommon patternsRun withinotifyto rebuild on source file changes.inotifywait--recursive--monitor--format"%e %w%f"\--eventmodify,move,create,delete./src\|whilereadchanged;doecho$changed(python3-mjinja2ssgbuild)donePut social links inside_social.yamlfiles and access as{{ yaml._social.facebook }}Access all build paths using{{ build_paths }}. Useful while writing
service worker code to cache the site as a PWA.Access{{ relative_path }}to know the path of the current file being rendered.
Package: jinja2_standalone_compiler
This provides a silly way to create HTML templates based on Jinja2 ones without a framework.This aims to be stupidly simple - in order to be used to whom have never heard about python before.The least you should do to work with this is learn a bit ofJinja2. Do it now, you won’t regret. =)Ah! This project works well on both Python2 and Python3.This is:a way to use Jinja2 outside python frameworks.a way to use Jinja2 not knowing anything in python.This is not:another templating language for python. Jinja2 is good enough.  =)Installation:pipinstalljinja2-standalone-compilerUsage:jinja2_standalone_compiler<path-to-jinja-files># Note that jinja files will be searched recursivelyFor a more intense usage, you can also use a settings file to define a bunch of things. To use settings file:jinja2_standalone_compiler<path-to-jinja-files>--settings=path/to/settings.pyYou can also use -s instead of –settingsPlease note that settings file is a Python file, so Python syntax applies. =PIt’s also possible to use multiple settings files, so that a template will be rendered multiple times with a different setup: -s <settings-1> -s <settings-2> …In order to see what can be done with this settings file, please refer tothis exampleTo turn off console ouput you can use the following option:jinja2_standalone_compiler<path-to-jinja-files>--silentOr if you want to get more console ouput:jinja2_standalone_compiler<path-to-jinja-files>--verboseYou can also specify an alternative output directory instead putting the rendered templates into the same directory as the jinja files. The relative directory structure (if present) will be reconstructed inside the new ouput. The ouput directory will be created if it doesn’t exist:jinja2_standalone_compiler<path-to-jinja-files>--out=<path-to-output-dir>You can also use -o instead of –outContributeDid you think in some interesting feature, or have you found a bug? Please let me know!Of course you can also download the project and send me somepull requests.You can send your suggestions byopening issues.You can contact me directly as well. Take a look at my contact information athttp://filwaitman.github.io/(email is preferred rather than mobile phone).
Package: jinja2_stl
A Filestorage template loader for Jinja2.FeaturesLoad templates fromDjango likestorageFree software: MIT licenseQuickstartInstall jinja2_stl:pip install jinja2_stlBasic usage:from jinja2 import Environment

from storage import Storage

from jinja2_stl.loader import FilestorageTemplateLoader


loader = FilestorageTemplateLoader(storage=Storage(...))
env = Environment(loader=loader)

template = env.get_template('foo/bar.html')

print(template.render(the='variables', go='here'))Storagemust implementsDjango Storage APIand is used as storage parameter inFilestorageTemplateLoader. The templatefoo/bar.htmlis loaded fromStoragethen is used in convenience way.History0.0.1 (2014-08-26)First release on PyPI.
Package: jinja2-strcase
jinja2-strcaseA python package for converting string case in jinja2 templates (including cookiecutter).It is a port of the go packagestrcaseInstallationjinja2-strcase is available for download from PyPI via pip:$ pip install jinja2-strcaseExamplefrom jinja2 import Environment

env = Environment(extensions=['jinja2_strcase.StrcaseExtension'])

# This will convert 'Any kind of string' -> 'any_kind_of_string'
template = env.from_string("{% 'Any kind of string' |  to_snake }")

template.render()FunctionResultto_snakeany_kind_of_stringto_screaming_snakeANY_KIND_OF_STRINGto_kebabany-kind-of-stringto_screaming_kebabANY-KIND-OF-STRINGto_camelAnyKindOfStringto_lower_camelanyKindOfString
Package: jinja2-stringcase
=================jinja2-stringcase=================.. image:: https://img.shields.io/pypi/v/jinja2_stringcase.svg:target: https://pypi.python.org/pypi/jinja2_stringcase.. image:: https://img.shields.io/travis/ufranske/jinja2_stringcase.svg:target: https://travis-ci.org/ufranske/jinja2_stringcase.. image:: https://readthedocs.org/projects/jinja2-stringcase/badge/?version=latest:target: https://jinja2-stringcase.readthedocs.io/en/latest/?badge=latest:alt: Documentation StatusJinja2 extension contains filters to convert case* Free software: MIT licenseCredits-------This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template... _Cookiecutter: https://github.com/audreyr/cookiecutter.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackageThis extension uses python-strincase_ library to convert cases... _stringcase: https://github.com/okunishinishi/python-stringcase=======History=======0.1.0 (2018-06-05)------------------* First release on PyPI.
Package: jinja2-time
Jinja2 Extension for Dates and TimesInstallationjinja2-timeis available for download fromPyPIviapip:$ pip install jinja2-timeIt will automatically installjinja2along witharrow.UsageNow TagThe extension comes with anowtag that provides convenient access to thearrow.now()API from your templates.You can control the output by specifying a format, that will be passed to
Python’sstrftime():fromjinja2importEnvironmentenv=Environment(extensions=['jinja2_time.TimeExtension'])# Timezone 'local', default format -> "2015-12-10"template=env.from_string("{% now 'local' %}")# Timezone 'utc', explicit format -> "Thu, 10 Dec 2015 15:49:01"template=env.from_string("{% now 'utc', '%a,%d%b %Y %H:%M:%S' %}")# Timezone 'Europe/Berlin', explicit format -> "CET +0100"template=env.from_string("{% now 'Europe/Berlin', '%Z %z' %}")# Timezone 'utc', explicit format -> "2015"template=env.from_string("{% now 'utc', '%Y' %}")template.render()Default Datetime FormatTimeExtensionextends the environment with adatetime_formatattribute.It is used as a fallback if you omit the format fornow.fromjinja2importEnvironmentenv=Environment(extensions=['jinja2_time.TimeExtension'])env.datetime_format='%a,%d%b %Y %H:%M:%S'# Timezone 'utc', default format -> "Thu, 10 Dec 2015 15:49:01"template=env.from_string("{% now 'utc' %}")template.render()Time Offsetjinja2-timeimplements a convenient interface to modifynowby a
relative time offset:# Examples for now "2015-12-09 23:33:01"# "Thu, 10 Dec 2015 01:33:31""{% now 'utc' + 'hours=2, seconds=30' %}"# "Wed, 09 Dec 2015 23:22:01""{% now 'utc' - 'minutes=11' %}"# "07 Dec 2015 23:00:00""{% now 'utc' - 'days=2, minutes=33, seconds=1', '%d%b %Y %H:%M:%S' %}"Further documentation on the underlying functionality can be found in thearrow replace docs.IssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.Code of ConductEveryone interacting in the jinja2-time project’s codebases, issue trackers, chat
rooms, and mailing lists is expected to follow thePyPA Code of Conduct.LicenseDistributed under the terms of theMITlicense, jinja2-time is free and open source software
Package: jinja2utils
jinja2utilsUseful utils for jinja2Installpipinstalljinja2utilst_factoryt_factory is a small tool which helps prefixed templates easily.See examples below.Example:./templates/en/home/welcomeWelcome, {{username}}!./templates/en/home/goodbyeWelcome, {{username}}!./templates/ru/home/welcomeWelcome, {{username}}!./templates/ru/home/goodbyeGoodbye, {{username}}!./main.pyfromjinja2importEnvironment,PrefixLoader,FileSystemLoaderfromjinja2utilsimportt_factoryloader=PrefixLoader({'en':FileSystemLoader('./templates/en'),'ru':FileSystemLoader('./templates/ru'),})jinja=Environment(loader=loader)get_t=t_factory(jinja)defprint_templates(t,username):rendered1=t('home/welcome',username=username)print(rendered1)rendered2=t('home/goodbye',username=username)print(rendered2)print_templates(get_t('en'),'John Doe')# Expected output:# Welcome, John Doe!# Goodbye, John Doe!print_templates(get_t('ru'),'Иван')# Expected output:# Привет, Иван!# Пока, Иван!pluralpluralis jinja2 filter function for easy text pluralization.Example:./templates/info/usersSystem have {{users}} active {{users|plural('en','user','users')}}.# main.pyfromjinja2importEnvironment,FileSystemLoaderfromjinja2utilsimportpluraljinja=Environment(loader=FileSystemLoader('./templates'))jinja.filters['plural']=pluraltemplate1=jinja.get_template('info/users')rendered1=template1.render(users=1)print(rendered1)# System have 1 active user.rendered2=template1.render(users=23)print(rendered2)# System have 23 active users.elapsed and remainingCalculates and formats elapsed time to string like this:25d 4h 3m 35s. Can be used as jinja2 filter.Example:./templates/infoSystem uptime: {{started|elapsed(show_seconds=True)}}../templates/newyearSystem uptime: {{started|elapsed(show_seconds=True)}}.# main.pyfromjinja2importEnvironment,FileSystemLoaderfromjinja2utilsimportelapsed,remainingimportdatetimejinja=Environment(loader=FileSystemLoader('./templates'))jinja.filters['elapsed']=elapsedjinja.filters['remaining']=remainingstarted=datetime.datetime.now()newyear=datetime.datetime(2025,1,1,0,0,0)username='John Doe'template1=jinja.get_template('info/uptime')rendered1=template1.render(started=started)print(rendered1)# System uptime: 25d 4h 3m 35s.template2=jinja.get_template('info/newyear')rendered2=template2.render(newyear=newyear)print(rendered2)# To next year remaining 295d 10h 13m 10s!ucharSimple jinja2 function to insert unicode characters
by unicode names. Very useful for inserting emoji.Example:./templates/info/usersWelcome, {{username}} {{UN('THUMBS UP SIGN')}}!# main.pyfromjinja2importEnvironment,FileSystemLoaderfromjinja2utilsimportucharjinja=Environment(loader=FileSystemLoader('./templates'))jinja.globals['UN']=uchartemplate1=jinja.get_template('info/users')rendered1=template1.render(username='John Doe')print(rendered1)# Welcome, John Doe 👍!