{ "info": { "author": "Santiago Videla", "author_email": "santiago.videla@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.5", "Topic :: Internet :: WWW/HTTP" ], "description": "Introduction\n============\n\nmegrok.jinja makes it possible to use Jinja2 templates in Grok.\n\nFor more information about Grok and Jinja2 visit:\n\n- http://grok.zope.org/\n- http://jinja.pocoo.org/\n\nRequirements\n------------\n\n- Grok v1.0a or later. Tested with Grok v1.0a2.\n- Jinja v2.1.1 or later. Tested with Jinja v2.1.1\n- PyYAML v3.08 or later. Tested with PyYAML v3.08\n- simplejson v1.7.1 or later. Tested with simplejson v1.7.1\n\nInstallation\n------------\n\nTo use the Jinja2 templates within Grok, megrok.jinja must be first\ninstalled as an egg, and its ZCML included. After using grokproject,\namend the setup.py to look like this::\n\n install_requires=[''setuptools',\n 'grok',\n 'megrok.jinja',\n # Add extra requirements here\n ],\n\nThen include megrok.jinja in your configure.zcml. It should look\nsomething like this::\n\n \n \n \n \n \n\nRerun buildout (bin/buildout), giving you something like:\n\n Getting distribution for 'megrok.jinja'.\n Got megrok.jinja 0.1\n\nThat's it. You can now place Jinja2 templates (with the `.jinja` extension)\ninto any template directory used within your project.\n\nJinja2 Environment\n------------------\n\nmegrok.jinja creates an Environment using `jinja2.ext.i18n` extension and overrides\nthe globals variables `_` and `gettext` in order to use custom functions to resolve\ntranslations. It also set the global variable `provider` as a function to resolve\nthe call to a content provider (viewlet manager).\n\nFor more information about Jinja2 Environment and Global variables visit:\n\n- http://jinja.pocoo.org/2/documentation/api#high-level-api\n- http://jinja.pocoo.org/2/documentation/api#the-global-namespace\n\nWith the extensions added you are able to use\n - zope.i18n messages factory\n - content providers like viewlets\n\nTo translate your templates, just register your translations domain and then\nyou can write::\n\n {% set i18n_domain='test_domain' %}\n\n {{ _('some-msgid')}}\n\nAlso it's possible to use the {%trans%} tag::\n\n {% set i18n_domain='test_domain' %}\n\n {% trans %}\n Whatever you may want to translate.\n {% endtrans %}\n\n\nIt's important to note that, `messages` created in python classes\nwon't be translated like in Zope Page Templates.\n\nIf you write:\n\nview.py::\n\n from zope import i18nmessageid\n _ = i18nmessageid.MessageFactory('some.domain')\n\n class Something(grok.View):\n def update(self):\n self.msg = _('Some msg id')\n\nview.jinja::\n\n {{ view.msg }}\n\nYou will always get 'Some msg id'. What you do could write is:\n\nview.py::\n\n class Something(grok.View):\n def update(self):\n self.msg = 'Some msg id'\n\nview.jinja::\n\n {% set i18n_domain='some.domain' %}\n\n {{ _(view.msg) }}\n\nNote that megrok.jinja uses the `translate` function from\nzope.i18n.interfaces.ITranslationDomains, so using::\n\n {{ _('msg_id') }}\n\nyou can pass all the parameters accepted by `translate`::\n\n {{ _('msg_id', domain='another_domain', target_language='es') }}\n\nIf you want to call some content provider named 'manager', just write::\n\n {{ provider('manager') }}\n\nAbout `.json` extension and PyYAML\n----------------------------------\n\nFor more information about PyYAML visit:\n- http://pyyaml.org/wiki/PyYAML\n\nmegrok.jinja allows you to write templates with `.json` extension and\ninside it, you are able to mix the Jinja2 syntax with PyYAML.\n\nFirst, megrok.jinja will try to parse the template using Jinja2\nand the result it's passed to the PyYAML loader. If PyYAML it's\nable to load the string passed, the result it's returned with simplejson.dumps\n\nIf you write this in a template with `.json` extension::\n\n dicts :\n - key1 : some_text\n - key2 : {{ 'Some Jinja2 expression' }}\n {% set l = ['3','4'] %}\n {% for v in l %}\n - {{ 'key-' + v }} : whatever {{ v }}\n {% endfor %}\n\nYou will get the next JSON::\n\n {\"dicts\": [{\"key1\": \"some_text\"},\n {\"key2\": \"Some Jinja2 expression\"},\n {\"key-3\": \"whatever 3\"},\n {\"key-4\": \"whatever 4\"}]}\n\n\nAuthors\n-------\n\n- Santiago Videla\n\n\n\nChangelog\n=========\n\n0.1 (2009-05-03)\n----------------\n\nInitial public release.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://svn.zope.org/megrok.jinja/", "keywords": "grok Jinja2", "license": "ZPL", "maintainer": null, "maintainer_email": null, "name": "megrok.jinja", "package_url": "https://pypi.org/project/megrok.jinja/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/megrok.jinja/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://svn.zope.org/megrok.jinja/" }, "release_url": "https://pypi.org/project/megrok.jinja/0.1/", "requires_dist": null, "requires_python": null, "summary": "Jinja2 templates integration in Grok", "version": "0.1" }, "last_serial": 794641, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ebacb92c8a301b40976ad87dc9feff9e", "sha256": "668a44a95e4fb64ea3265054b2f518b1de6f76234f4277532efcd0feb20a2101" }, "downloads": -1, "filename": "megrok.jinja-0.1.tar.gz", "has_sig": false, "md5_digest": "ebacb92c8a301b40976ad87dc9feff9e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12195, "upload_time": "2009-05-04T00:20:19", "url": "https://files.pythonhosted.org/packages/a6/4a/8ec13d048e2ea7fdf423dd59b43140866d3c4a3b4430e40fb3fb6347e4af/megrok.jinja-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ebacb92c8a301b40976ad87dc9feff9e", "sha256": "668a44a95e4fb64ea3265054b2f518b1de6f76234f4277532efcd0feb20a2101" }, "downloads": -1, "filename": "megrok.jinja-0.1.tar.gz", "has_sig": false, "md5_digest": "ebacb92c8a301b40976ad87dc9feff9e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12195, "upload_time": "2009-05-04T00:20:19", "url": "https://files.pythonhosted.org/packages/a6/4a/8ec13d048e2ea7fdf423dd59b43140866d3c4a3b4430e40fb3fb6347e4af/megrok.jinja-0.1.tar.gz" } ] }