{ "info": { "author": "Syrus Akbary", "author_email": "me@syrusakbary.com", "bugtrack_url": null, "classifiers": [], "description": "======\nPyJade\n======\n\nPyJade is a high performance port of Jade-lang for python, that converts any .jade source to the each Template-language (Django, Jinja2, Mako or Tornado).\n\n\nUTILITIES\n=========\nTo simply output the conversion to your console::\n\n pyjade [-c django|jinja|mako|tornado] input.jade [output.html]\n\n\nINSTALLATION\n============\n\nFirst, you must do::\n\n pip install pyjade\n\nOr::\n\n python setup.py install\n\nNow simply **name your templates with a `.jade` extension** and this jade compiler\nwill do the rest. Any templates with other extensions will not be compiled\nwith the pyjade compiler.\n\n\nDjango\n------\n\nIn `settings.py`, add a `loader` to `TEMPLATES` like so:\n\n.. code:: python\n\n TEMPLATES = [\n {\n 'BACKEND': 'django.template.backends.django.DjangoTemplates',\n 'DIRS': [],\n 'OPTIONS': {\n 'context_processors': [\n 'django.template.context_processors.debug',\n 'django.template.context_processors.request',\n 'django.contrib.auth.context_processors.auth',\n 'django.contrib.messages.context_processors.messages',\n 'django.core.context_processors.request'\n ],\n 'loaders': [\n # PyJade part: ##############################\n ('pyjade.ext.django.Loader', (\n 'django.template.loaders.filesystem.Loader',\n 'django.template.loaders.app_directories.Loader',\n ))\n ],\n 'builtins': ['pyjade.ext.django.templatetags'], # Remove this line for Django 1.8\n },\n },\n ]\n\n\nJinja2\n------\n\nJust add `pyjade.ext.jinja.PyJadeExtension` as extension\n\n.. code:: python\n\n jinja_env = Environment(extensions=['pyjade.ext.jinja.PyJadeExtension'])\n\n\nMako\n----\n\nJust add `pyjade.ext.mako.preprocessor` as preprocessor\n\n.. code:: python\n\n from pyjade.ext.mako import preprocessor as mako_preprocessor\n mako.template.Template(haml_source,\n preprocessor=mako_preprocessor\n )\n\n\nFlask\n-----\n\nJust add `pyjade.ext.jinja.PyJadeExtension` as extension to the environment of the app\n\n.. code:: python\n\n app.jinja_env.add_extension('pyjade.ext.jinja.PyJadeExtension')\n\n\nPyramid\n-------\n\nAdjust your \"your_project/__init__.py\" and add the following line somewhere to in the main() function\n\n.. code:: python\n\n config.include('pyjade.ext.pyramid')\n\n\nTornado Templates\n-----------------\n\nAppend this after importing tornado.template\n\n.. code:: python\n\n from tornado import template\n from pyjade.ext.tornado import patch_tornado\n patch_tornado()\n\n (...)\n\n\nSyntax\n======\n\nExactly the same as the Jade Node.js module (except of cases, which are not implemented)\nhttps://github.com/visionmedia/jade/blob/master/README.md\n\n\nExample\n-------\n\nThis code\n\n.. code:: jade\n\n !!! 5\n html(lang=\"en\")\n head\n title= pageTitle\n script(type='text/javascript')\n if (foo) {\n bar()\n }\n body\n h1.title Jade - node template engine\n #container\n if youAreUsingJade\n p You are amazing\n else\n p Get on it!\n\n\nConverts to\n\n.. code:: html\n\n \n \n
\nYou are amazing
\n {%else%}\nGet on it!
\n {%endif%}\n