jinja-script-block


Namejinja-script-block JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/jinrudals/jinja2_script.git
Summary
upload_time2023-01-30 00:31:09
maintainer
docs_urlNone
authorBenjamin Jin
requires_python
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Jinja2 Script

## Introduction
In ERB, custom functions can be written in the template. However with jinja2, the functions should be written in python, and must be included in the rendering environment.

## Use Script Block
```jinja2
{% script modulename %}
  # Your Python Code that should be in .py
{% endscript %}
```
Define your python codes in script block. This is compiled before actual run starts.

To use compiled block, do it as following:
```
{{module.functions_you_defined()}}
{{module.values_you_defined()}}
{{module.function_with_arguments(1)}}
{{module.function_with_arguments_at_render(x)}}
```

## How to use
```python3
from jinja_script_block import ScriptBlockExtension
from jinja2 import Environment

env = Environment(extensions=[ScriptBlockExtension])

env.from_string('''
{% script mymodule %}
class MyClass:
  containers = []
{% endscript%}
''')
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jinrudals/jinja2_script.git",
    "name": "jinja-script-block",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Benjamin Jin",
    "author_email": "jinrudals135@naver.com",
    "download_url": "https://files.pythonhosted.org/packages/ea/4a/dd39837f273c948d4f9ee137eec7669b6c06d71d65674583f8e22370edd0/jinja-script-block-0.0.4.tar.gz",
    "platform": null,
    "description": "# Jinja2 Script\n\n## Introduction\nIn ERB, custom functions can be written in the template. However with jinja2, the functions should be written in python, and must be included in the rendering environment.\n\n## Use Script Block\n```jinja2\n{% script modulename %}\n  # Your Python Code that should be in .py\n{% endscript %}\n```\nDefine your python codes in script block. This is compiled before actual run starts.\n\nTo use compiled block, do it as following:\n```\n{{module.functions_you_defined()}}\n{{module.values_you_defined()}}\n{{module.function_with_arguments(1)}}\n{{module.function_with_arguments_at_render(x)}}\n```\n\n## How to use\n```python3\nfrom jinja_script_block import ScriptBlockExtension\nfrom jinja2 import Environment\n\nenv = Environment(extensions=[ScriptBlockExtension])\n\nenv.from_string('''\n{% script mymodule %}\nclass MyClass:\n  containers = []\n{% endscript%}\n''')\n```\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "",
    "version": "0.0.4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6db12c7066d925568244edd7da63b5e32157b8381cbad25116b3d0b28a07976",
                "md5": "672b00b2228b6bbed3196bcf49bf368f",
                "sha256": "1a1951c3993524ae646648837a8f2089bc595a6eec5d4e73a2f4f8d2d3f62970"
            },
            "downloads": -1,
            "filename": "jinja_script_block-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "672b00b2228b6bbed3196bcf49bf368f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 2454,
            "upload_time": "2023-01-30T00:31:07",
            "upload_time_iso_8601": "2023-01-30T00:31:07.842625Z",
            "url": "https://files.pythonhosted.org/packages/c6/db/12c7066d925568244edd7da63b5e32157b8381cbad25116b3d0b28a07976/jinja_script_block-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ea4add39837f273c948d4f9ee137eec7669b6c06d71d65674583f8e22370edd0",
                "md5": "a5ea5aec161835df3f00d59284ce9a11",
                "sha256": "519aa8051a8250f5c25e3b75a9fa95ee36dac9b8a15ab588f2e2d6341406c2dc"
            },
            "downloads": -1,
            "filename": "jinja-script-block-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "a5ea5aec161835df3f00d59284ce9a11",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 2375,
            "upload_time": "2023-01-30T00:31:09",
            "upload_time_iso_8601": "2023-01-30T00:31:09.382220Z",
            "url": "https://files.pythonhosted.org/packages/ea/4a/dd39837f273c948d4f9ee137eec7669b6c06d71d65674583f8e22370edd0/jinja-script-block-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-30 00:31:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "jinrudals",
    "github_project": "jinja2_script.git",
    "lcname": "jinja-script-block"
}
        
Elapsed time: 0.05172s