{ "info": { "author": "Z. Alem", "author_email": "alem@cidola.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License" ], "description": "RNDR is a simple templating engine that unleashes the\nfull power of Python within templates.\n\nDeriving much inspiration from PHP's templating system, RNDR\naims to exploit Python's inherent utility for templating in\na manner that is simple, configurable, and requiring little to learn.\n\nUsage\n-----\n\nSyntax\n~~~~~~\nRNDR's syntax is easy to learn as it involves little more than\nenclosing a single-line Python statement within a pair of tags. \n\nThese tags, the start-tag and the end-tag, are by default ``@R`` and ``R@``\nrespectively. \n\n>>> r = RNDR( \n... \"\"\n... \"@R echo( 1 + 1 ) R@\"\n... \"\" \n... )\n>>> r.render()\n'2'\n\nThe output function ``echo`` is used in-place of Python's ``print`` as the latter\nappends a new line, which may or may not be desirable.\n\nRather than calling the ``echo`` function one may also use the output tag:\na start tag appended, by default, with an equal sign:\n\n>>> r = RNDR( \n... \"\"\n... \"@R= 1 + 1 R@\"\n... \"\" \n... )\n>>> r.render()\n'2'\n\nThe Python language groups the statement blocks of control structures through\nthe use of indentation. Unfortunately, using indentation as a means for\nmanaging control-structures within templates is restrictive, fragile, and\ngenerally unpleasant.\n\nIn its place RNDR allows control structures to be explicitly terminated by\nproviding a control-structure termination statement: ``end``.\n\n>>> r = RNDR( \n... \"\"\n... \" Hello\"\n... \"@R if 1+1 is 2: R@\"\n... \" World! \"\n... \"@R endif R@\"\n... \"\" \n... )\n>>> print( r.render() )\n Hello World! \n\nThe syntax described so far is akin to (and drew its inspiration from) the PHP\ntemplating engine.\n\nMuch like the PHP templating engine, there is no esoteric or neutered\ntemplating language to learn: RNDR simply executes Python code placed within\nstatement tags. \n\n>>> r = RNDR(\n... \"\"\n... \"@R for i in [1,2,3]: R@\"\n... \"@R= i R@ \"\n... \"@R endfor R@\"\n... \"\"\n... )\n>>> print( r.render() )\n1 2 3 \n\n>>> r = RNDR(\n... \"\"\n... \"@R i = 0 R@\"\n... \"@R while True: R@\"\n... \"@R i += 1 R@\"\n... \"@R if i == 3: R@\"\n... \" I'm finally three! \"\n... \"@R break R@\"\n... \"@R endif R@\"\n... \"@R endwhile R@\"\n... \"\"\n... )\n>>> print( r.render() )\n I'm finally three! \n\nOne can take this to great extremes:\n\n>>> r = RNDR(\n... \"\"\n... \"@R try: R@\"\n... \"@R 1/0 R@\"\n... \"@R except Exception as e: R@\"\n... \" @R= e R@ is fun! \"\n... \"@R endtry R@\"\n... \"\"\n... )\n>>> print( r.render() )\n integer division or modulo by zero is fun! \n\nWith respect to the principle of concern separation, seldom could\nsuch practice be considered a good idea. \nIdeally, complex or sensitive functionality should be contained in a domain\nremoved from presentation; logic delegated to the template should be the\nsimplest kind able to perform the given task.\n\n\n \n\nTemplates and Context\n~~~~~~~~~~~~~~~~~~~~~\nRNDR accepts templates in the form of Python strings ( both bytestrings and\nunicode ), and file objects.\n\n>>> f = open('test.rndr.xml','w')\n>>> r = f.write( \n... \"\"\n... \"@R= 1+1 R@\"\n... \"\" \n... )\n>>> f.close()\n>>> r = RNDR( open('test.rndr.xml') )\n>>> r.render()\n'2'\n\nRNDR also accepts context variables: the variables that will provide the\nnamespace for statements found in the template.\n\n>>> r = RNDR( \n... \"\"\n... \"@R= my_var R@\"\n... \"\" \n... )\n>>> r.render( {'my_var': 'Hello'} )\n'Hello'\n\nThese context variables may be of any type.\n\n>>> r = RNDR( \n... \"\"\n... \"@R= my_func('Moe') R@\"\n... \"\" \n... )\n>>> r.render( {'my_func': lambda x: \"Hello \" + x } )\n'Hello Moe'\n\n\nFile and Template Inclusion\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRNDR also supports the inclusion of files and other RNDR templates into a\ntemplate.\nThe content of a file inclusion statement takes the form: ::\n\n \"filename\" | filename_variable\n\nThe ``include_tag_suffix`` is the tag leading the ``start_tag`` of a\nstatement. By default, the ``include_tag_suffix`` is an opening angle bracket\n('<'). ::\n\n @R< \"filename\" R@\n @R< filename_variable R@\n\nTemplates included into other templates will share the same\ncontext variables.\n\nTo provide a complete illustration:\n\n>>> with open('plain.txt','w') as plain, open('renderable.rndr.txt','w') as renderable:\n... plain.write(\n... \" Hello World. \"\n... )\n... renderable.write(\n... \"@R if name: R@\"\n... \"Hello @R= name R@.\"\n... \"@R endif R@\"\n... )\n>>> r = RNDR(\n... \"\"\n... \"@R< 'plain.txt' R@\"\n... \"@R< 'renderable.rndr.txt' R@\"\n... \"\"\n... )\n>>> print( r.render( context = {'name':'Moe'} ) )\n Hello World. Hello Moe.\n\n\nDjango Integration\n~~~~~~~~~~~~~~~~~~\n\nSome users may want to integrate RNDR into their Django projects. This can be\ndone quite easily: simply insert the line ``\"rndr.loaders.RNDRLoader\"`` into the\n``TEMPLATE_LOADERS`` list in your projects settings.py file.\nNote that the RNDR template loader will **only** load templates that contain the \nnested/secondary extension '.rndr' (e.g. template.rndr.html ). ::\n\n TEMPLATE_LOADERS = (\n 'rndr.loaders.FileSystemLoader',\n 'rndr.loaders.AppDirectoriesLoader',\n ...\n )\n\n\nCommand-line interface\n~~~~~~~~~~~~~~~~~~~~~~\n\nRNDR also includes a very simple console interface for rendering template\nin a command-line environment.\n\nThere are two positional arguments that may be passed. The first is the path of\nthe template file and the second is the file to which rendered content will\nbe written to. ::\n \n $ python -m rndr template.rndr.html rendered.html\n\nThey default to the standard input and output streams respectively, meaining\nthey can be used in pipes and standard stream redirections. ::\n\n $ echo \"@R if True: R@ Hello @R endfor R@\" | python -m rndr\n Hello\n\n $ echo \"@R for i in (1,2,3): R@ Hello @R endfor R@\" | python -m rndr > rendered.html\n\nOne may also provide the context variables for a template by creating a\nfile containing an evaluatable Python dictionary expression ( e.g.\n``{'context_var':123}`` ) or a JSON array (e.g. ``{ \"context_var\":123 }`` ) and providing\nits file path as the value for the ``-c`` or ``--context`` arguments. ::\n\n python -m rndr template.rndr.html rendered.html -c context.py\n\nFinally, one may retrieve the version number by passing the ``-v`` \nand ``--version`` arguments, or the help message via ``-h`` and ``--help``.\n\n\nConfiguration\n-------------\n\nRNDR permits the configuration of a few of its features: tags, \ncontrol structure tracking, and the output function used to print\nrendered components.\n\nTags\n~~~~\nStart tags, end tags, and output suffix tags are all customizable.\n\n>>> identical_tags_config = Config( \n... start_tag = '||', end_tag='||' \n... )\n>>> r = RNDR( \n... \"\"\n... \" Hello\"\n... \"|| if 1+1 is 3: ||\"\n... \" Fail\"\n... \"|| else: ||\"\n... \" World! \"\n... \"|| endif ||\"\n... \"\", identical_tags_config\n... )\n>>> print( r.render() )\n Hello World! \n\nSo too are block-start and block-end tags.\n\n>>> custom_block_tags = Config( \n... block_start_tag = 'then',\n... block_end_tag = 'end ',\n... )\n>>> r = RNDR( \n... \"\"\n... \"@R if 1 + 1 then R@\"\n... \" Hello \"\n... \"@R end if R@\"\n... \"\", custom_block_tags\n... )\n>>> r.render()\n' Hello '\n\n\nControl-structure tracking\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nBy default, RNDR tracks control structures: every time a control structure\nis initiated (e.g. ``if A == B:`` ) it will be recorded as being active until\nexplicitly terminated (e.g. ``endif``). This allows RNDR to determine exactly\nwhat control structures are active or unterminated, and how to manage the\nindentation of the virtual source built from the statements.\n\nThis feature can be disabled. This will result in RNDR being unable to track the\nparticular control structures active, and will require explicit block\nmanagement through use of the ``block_start_tag`` and ``block_end_tag``\nsymbols.\n\nThe start of a block is denoted by the block_start symbol, which is found at\nthe end of a statement. The end of a block is denoted by the block_end symbol,\nwhich is found at the beginning of a statement. By default, both use the colon (':').\n\n>>> rc = Config( cs_tracking = False )\n>>> r = RNDR( \n... \"\"\n... \" Hello\"\n... \"@R if 1+1 is 3: R@\"\n... \" Fail\"\n... \"@R :else: R@\"\n... \" World! \"\n... \"@R :end R@\"\n... \"\", rc\n... )\n>>> print( r.render() )\n Hello World! \n\nThis syntax is similar to that of the Templite+ templating engine.\nTaking advantage of the configurable ``start_tag`` and ``end_tag`` values,\nRNDR can fully support a Templite+ template.\n\n>>> templite_config = Config( \n... cs_tracking = False, start_tag = '<<', end_tag='>>', \n... )\n>>> r = RNDR( \n... \"\"\n... \" Hello\"\n... \"<< if 1+1 is 3: >>\"\n... \" Fail\"\n... \"<< :else: >>\"\n... \" World! \"\n... \"<< :endif >>\"\n... \"\", templite_config\n... )\n>>> print( r.render() )\n Hello World! ", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://rndrengine.com", "keywords": "templates,templating,templating engine,render templates,eval", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "RNDR", "package_url": "https://pypi.org/project/RNDR/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/RNDR/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://rndrengine.com" }, "release_url": "https://pypi.org/project/RNDR/1.1.8/", "requires_dist": null, "requires_python": null, "summary": "A simple and powerful templating engine.", "version": "1.1.8" }, "last_serial": 1760874, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "42de50bec944a8086b6ce6b8260876b8", "sha256": "bffa4b17403a16a804ddaaf2f2acbd12967a0f626055c18145f247c860b33995" }, "downloads": -1, "filename": "RNDR-1.0.1.tar.gz", "has_sig": false, "md5_digest": "42de50bec944a8086b6ce6b8260876b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16772, "upload_time": "2013-04-07T09:38:53", "url": "https://files.pythonhosted.org/packages/e2/e7/a85c68c81ac22cd6c8e55ea3d1a40aeb21c1c27a29f8459f9f885c8ed2cb/RNDR-1.0.1.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "c72c7844c36893087daadcd8db258880", "sha256": "6ca80df8484fafd73db0cfe240aeeb9c36f2eebfd46633314c518f49d976b2a9" }, "downloads": -1, "filename": "RNDR-1.1.3.tar.gz", "has_sig": false, "md5_digest": "c72c7844c36893087daadcd8db258880", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19701, "upload_time": "2013-05-05T07:47:34", "url": "https://files.pythonhosted.org/packages/6f/33/716f9e35e6f4c4b041a97d245120066228ec043a63069a2472b1006de170/RNDR-1.1.3.tar.gz" } ], "1.1.5": [ { "comment_text": "", "digests": { "md5": "1d9e1f48fce81f60f3a420b5283194e0", "sha256": "b435efaf854d2ad879161ba4d8b7d91e95565c02d6ecc3e33fdbba25de8774ce" }, "downloads": -1, "filename": "RNDR-1.1.5.tar.gz", "has_sig": false, "md5_digest": "1d9e1f48fce81f60f3a420b5283194e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19363, "upload_time": "2013-10-27T01:06:38", "url": "https://files.pythonhosted.org/packages/ad/0a/f9b9c1827d8fbf8abf99c9e0398868ce0ba19a53c76178764e464c74b181/RNDR-1.1.5.tar.gz" } ], "1.1.8": [ { "comment_text": "", "digests": { "md5": "37a97828646c6f6b5c4ee2d3072e7aea", "sha256": "15b09386edb78256b72ecd530420f05cf8afa32d3354c0c07c2f59e113ab21a8" }, "downloads": -1, "filename": "RNDR-1.1.8.tar.gz", "has_sig": false, "md5_digest": "37a97828646c6f6b5c4ee2d3072e7aea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19241, "upload_time": "2015-10-10T02:16:02", "url": "https://files.pythonhosted.org/packages/91/e8/71cbc1d1c7145a04f5f3542a9bcde54587977e866849b3367c0bc9953039/RNDR-1.1.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "37a97828646c6f6b5c4ee2d3072e7aea", "sha256": "15b09386edb78256b72ecd530420f05cf8afa32d3354c0c07c2f59e113ab21a8" }, "downloads": -1, "filename": "RNDR-1.1.8.tar.gz", "has_sig": false, "md5_digest": "37a97828646c6f6b5c4ee2d3072e7aea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19241, "upload_time": "2015-10-10T02:16:02", "url": "https://files.pythonhosted.org/packages/91/e8/71cbc1d1c7145a04f5f3542a9bcde54587977e866849b3367c0bc9953039/RNDR-1.1.8.tar.gz" } ] }