pypugjs


Namepypugjs JSON
Version 5.10.1 PyPI version JSON
download
home_pagehttps://github.com/kakulukia/pypugjs
SummaryPugJS syntax template adapter for Django, Jinja2, Mako and Tornado templates
upload_time2024-05-22 11:00:10
maintainerNone
docs_urlNone
authorAndy Grabow
requires_pythonNone
licenseMIT
keywords pug pugjs template converter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            PyPugJS |PyPiPackage|_ |BuildStatus|_ |Coverage|_
===================================================

.. |PyPiPackage| image:: https://badge.fury.io/py/pypugjs.svg
.. _PyPiPackage: https://badge.fury.io/py/pypugjs

.. |BuildStatus| image:: https://travis-ci.org/kakulukia/pypugjs.svg
.. _BuildStatus: https://travis-ci.org/kakulukia/pypugjs

.. |Coverage| image:: https://codecov.io/gh/kakulukia/pypugjs/branch/master/graph/badge.svg
.. _Coverage: https://codecov.io/gh/kakulukia/pypugjs

**PyPugJS is a fork of** `PyJade <http://github.com/syrusakbary/pyjade>`_
**with the name Jade changed to** `PugJS <https://github.com/pugjs/pug>`_.

**Additional disclaimer:** Since the original pypugjs died i took the liberty to keep it alive, because
since starting to work with the jade compiler for node I hate writing HTML and want to continue using it in my Django projects.
I will keep the existing non Django stuff inside the project, but I cannot support anything other since I'm not actively using
it not will be in the foreseable future. Tornado, Mako etc. support will be welcome tho!

PyPugJS is a high performance port of PugJS for python, that converts any .pug source into different
Template-languages (Django, Jinja2, Mako or Tornado).

UTILITIES
=========
To simply output the conversion to your console::

    pypugjs [-c django|jinja|mako|tornado] input.pug [output.html]

INSTALLATION
============

To install pypugjs::

    pip install pypugjs

Now simply **name your templates with a `.pug` extension** and this PugJS compiler
will do the rest.  Any templates with other extensions will not be compiled
with the pypugjs compiler.

`Framework specific installation instructions <docs/installation.rst>`_

Syntax
======

Generally the same as the PugJS Node module (except of cases and several other features, which are not implemented)
https://github.com/pugjs/pug/blob/master/README.md


Example
-------

This code

.. code:: pug

    !!! 5
    html(lang="en")
      head
        title= pageTitle
        script(type='text/javascript').
          if (foo) {
             bar()
          }
      body
        h1.title PugJS - node template engine
        #container
          if youAreUsingPugJS
            p You are amazing
          else
            p Get on it!


Converts to

.. code:: html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <title>{{pageTitle}}</title>
        <script type='text/javascript'>
          if (foo) {
             bar()
          }
        </script>
      </head>
      <body>
        <h1 class="title">PugJS - node template engine</h1>
        <div id="container">
          {%if youAreUsingPugJS%}
            <p>You are amazing</p>
          {%else%}
            <p>Get on it!</p>
          {%endif%}
        </div>
      </body>
    </html>

Convert existing templates online with the `HTML2Jade converter <http://www.html2jade.org/>`_.


Register filters
================

If you want to register a function as a filter, you only have to
decorate the function with ``pypugjs.register_filter("filter_name")``

.. code:: python

    import pypugjs

    @pypugjs.register_filter('capitalize')
    def capitalize(text, ast):
      return text.capitalize()


Notable Features
===================

Adding conditional classes:

.. code:: pug

    a(class={'active-class': True, 'another': False})

Define mixins like this *mixins/foo.pug*:

.. code:: pug

    mixin foo(data)
      .foo {{ data }}

And use them in your templates like this:

.. code:: pug

    include mixins/foo.pug

    div
      +foo(data)


*Mixins might not work, depending on the used Framework.
The following have been reported as broken:*

* Django (v4.2)


TESTING
=======

To start the testsuite, start the following commands::

    make init
    make test

TODOs and BUGS
==============
See: https://github.com/kakulukia/pypugjs/issues

`ChangeLog <docs/HISTORY.rst>`_




History
-------

\*

* django docs: mention not to wrap with django's caching template loader
* updated history

5.8.1
+++++++
* mentioning the flask example in the installation section of the docs
* prevent endless recursion in Django template overriding

5.8.0
+++++++
* more details/docs for using pypugjs with jinja2
* fixed issue with Jinja Choiceloaders

5.7.2
+++++++
* Fix specifying attributes without commas.

5.7.1
+++++++
* code has been blacked

5.7.0
+++++++
* included encoding detection for template files

5.6.1
+++++++
* fixed documentation for the new translation call
* fixed typos in code
* added min Django version to the docs
* new release script

5.6.0
+++++++
* added enable_pug_translations call

5.5.1
+++++++
* fixed wrong exception handling for visitExtends

5.5.0
+++++++
* better caching for django template loader
* loader has been made compatible with django 1.11

5.4.0
+++++++
* added mixing to flask hello world
* Clean pipe inserts whitespace This allows for use of a single pipe character on a line to insert a whitespace before or after a tag.


5.3.0
+++++++
* fixed build script adding back all internal packages

5.2.0
+++++++
* fixed recursive import problem

5.1.5
+++++++
* addeded flake8 testing
* sorting out old Django version 1.11 and 2.0 are left for travis testing

5.1.4
+++++++
* better release script

5.1.3
+++++++
* cleanup / documentation
* extended makefile

5.1.2
+++++++

* added Makefile for testing, installing, releasing, linting ...
* added coverage reports
* package is mainly base on the cookiecutter package
* additional release helpers
* packages passes flake8 test


5.1.1
+++++++

* conditional classes feature (thx to paradoxxxzero)
* mixin support for jinja (matin)
* mixin support for django
* refactored the django tests to actually use the file loader
* some pep8 fixes


Authors
---------

* PyPugs was originally created as PyJade by Syrus Akbary in November 2011.
* It was then renamed maintained by Matan Noam Shavit
* Since I need it for my projects and hate coding plain HTML, I continued maintaining this package.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kakulukia/pypugjs",
    "name": "pypugjs",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "pug, pugjs, template, converter",
    "author": "Andy Grabow",
    "author_email": "andy@freilandkiwis.de",
    "download_url": "https://files.pythonhosted.org/packages/b2/fb/1b672c8f5b55ef09f7bf89dca48ceecc06e6230bbcdb999625021f6307e2/pypugjs-5.10.1.tar.gz",
    "platform": null,
    "description": "PyPugJS |PyPiPackage|_ |BuildStatus|_ |Coverage|_\n===================================================\n\n.. |PyPiPackage| image:: https://badge.fury.io/py/pypugjs.svg\n.. _PyPiPackage: https://badge.fury.io/py/pypugjs\n\n.. |BuildStatus| image:: https://travis-ci.org/kakulukia/pypugjs.svg\n.. _BuildStatus: https://travis-ci.org/kakulukia/pypugjs\n\n.. |Coverage| image:: https://codecov.io/gh/kakulukia/pypugjs/branch/master/graph/badge.svg\n.. _Coverage: https://codecov.io/gh/kakulukia/pypugjs\n\n**PyPugJS is a fork of** `PyJade <http://github.com/syrusakbary/pyjade>`_\n**with the name Jade changed to** `PugJS <https://github.com/pugjs/pug>`_.\n\n**Additional disclaimer:** Since the original pypugjs died i took the liberty to keep it alive, because\nsince starting to work with the jade compiler for node I hate writing HTML and want to continue using it in my Django projects.\nI will keep the existing non Django stuff inside the project, but I cannot support anything other since I'm not actively using\nit not will be in the foreseable future. Tornado, Mako etc. support will be welcome tho!\n\nPyPugJS is a high performance port of PugJS for python, that converts any .pug source into different\nTemplate-languages (Django, Jinja2, Mako or Tornado).\n\nUTILITIES\n=========\nTo simply output the conversion to your console::\n\n    pypugjs [-c django|jinja|mako|tornado] input.pug [output.html]\n\nINSTALLATION\n============\n\nTo install pypugjs::\n\n    pip install pypugjs\n\nNow simply **name your templates with a `.pug` extension** and this PugJS compiler\nwill do the rest.  Any templates with other extensions will not be compiled\nwith the pypugjs compiler.\n\n`Framework specific installation instructions <docs/installation.rst>`_\n\nSyntax\n======\n\nGenerally the same as the PugJS Node module (except of cases and several other features, which are not implemented)\nhttps://github.com/pugjs/pug/blob/master/README.md\n\n\nExample\n-------\n\nThis code\n\n.. code:: pug\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 PugJS - node template engine\n        #container\n          if youAreUsingPugJS\n            p You are amazing\n          else\n            p Get on it!\n\n\nConverts to\n\n.. code:: html\n\n    <!DOCTYPE html>\n    <html lang=\"en\">\n      <head>\n        <title>{{pageTitle}}</title>\n        <script type='text/javascript'>\n          if (foo) {\n             bar()\n          }\n        </script>\n      </head>\n      <body>\n        <h1 class=\"title\">PugJS - node template engine</h1>\n        <div id=\"container\">\n          {%if youAreUsingPugJS%}\n            <p>You are amazing</p>\n          {%else%}\n            <p>Get on it!</p>\n          {%endif%}\n        </div>\n      </body>\n    </html>\n\nConvert existing templates online with the `HTML2Jade converter <http://www.html2jade.org/>`_.\n\n\nRegister filters\n================\n\nIf you want to register a function as a filter, you only have to\ndecorate the function with ``pypugjs.register_filter(\"filter_name\")``\n\n.. code:: python\n\n    import pypugjs\n\n    @pypugjs.register_filter('capitalize')\n    def capitalize(text, ast):\n      return text.capitalize()\n\n\nNotable Features\n===================\n\nAdding conditional classes:\n\n.. code:: pug\n\n    a(class={'active-class': True, 'another': False})\n\nDefine mixins like this *mixins/foo.pug*:\n\n.. code:: pug\n\n    mixin foo(data)\n      .foo {{ data }}\n\nAnd use them in your templates like this:\n\n.. code:: pug\n\n    include mixins/foo.pug\n\n    div\n      +foo(data)\n\n\n*Mixins might not work, depending on the used Framework.\nThe following have been reported as broken:*\n\n* Django (v4.2)\n\n\nTESTING\n=======\n\nTo start the testsuite, start the following commands::\n\n    make init\n    make test\n\nTODOs and BUGS\n==============\nSee: https://github.com/kakulukia/pypugjs/issues\n\n`ChangeLog <docs/HISTORY.rst>`_\n\n\n\n\nHistory\n-------\n\n\\*\n\n* django docs: mention not to wrap with django's caching template loader\n* updated history\n\n5.8.1\n+++++++\n* mentioning the flask example in the installation section of the docs\n* prevent endless recursion in Django template overriding\n\n5.8.0\n+++++++\n* more details/docs for using pypugjs with jinja2\n* fixed issue with Jinja Choiceloaders\n\n5.7.2\n+++++++\n* Fix specifying attributes without commas.\n\n5.7.1\n+++++++\n* code has been blacked\n\n5.7.0\n+++++++\n* included encoding detection for template files\n\n5.6.1\n+++++++\n* fixed documentation for the new translation call\n* fixed typos in code\n* added min Django version to the docs\n* new release script\n\n5.6.0\n+++++++\n* added enable_pug_translations call\n\n5.5.1\n+++++++\n* fixed wrong exception handling for visitExtends\n\n5.5.0\n+++++++\n* better caching for django template loader\n* loader has been made compatible with django 1.11\n\n5.4.0\n+++++++\n* added mixing to flask hello world\n* Clean pipe inserts whitespace This allows for use of a single pipe character on a line to insert a whitespace before or after a tag.\n\n\n5.3.0\n+++++++\n* fixed build script adding back all internal packages\n\n5.2.0\n+++++++\n* fixed recursive import problem\n\n5.1.5\n+++++++\n* addeded flake8 testing\n* sorting out old Django version 1.11 and 2.0 are left for travis testing\n\n5.1.4\n+++++++\n* better release script\n\n5.1.3\n+++++++\n* cleanup / documentation\n* extended makefile\n\n5.1.2\n+++++++\n\n* added Makefile for testing, installing, releasing, linting ...\n* added coverage reports\n* package is mainly base on the cookiecutter package\n* additional release helpers\n* packages passes flake8 test\n\n\n5.1.1\n+++++++\n\n* conditional classes feature (thx to paradoxxxzero)\n* mixin support for jinja (matin)\n* mixin support for django\n* refactored the django tests to actually use the file loader\n* some pep8 fixes\n\n\nAuthors\n---------\n\n* PyPugs was originally created as PyJade by Syrus Akbary in November 2011.\n* It was then renamed maintained by Matan Noam Shavit\n* Since I need it for my projects and hate coding plain HTML, I continued maintaining this package.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PugJS syntax template adapter for Django, Jinja2, Mako and Tornado templates",
    "version": "5.10.1",
    "project_urls": {
        "Download": "https://github.com/kakulukia/pypugjs/tarball/5.10.1",
        "Homepage": "https://github.com/kakulukia/pypugjs"
    },
    "split_keywords": [
        "pug",
        " pugjs",
        " template",
        " converter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7370700d501c4fe810ad90d5ffaa6e6d13223095a20b7bbe5a994b3a816461c8",
                "md5": "62f35a575043e470e43ff8385d94aab0",
                "sha256": "c812f6d79c20a450d3495cdbd75bc8eb6e7a3220c0a6b511da5d44b40d162e28"
            },
            "downloads": -1,
            "filename": "pypugjs-5.10.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "62f35a575043e470e43ff8385d94aab0",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 36755,
            "upload_time": "2024-05-22T11:00:07",
            "upload_time_iso_8601": "2024-05-22T11:00:07.142685Z",
            "url": "https://files.pythonhosted.org/packages/73/70/700d501c4fe810ad90d5ffaa6e6d13223095a20b7bbe5a994b3a816461c8/pypugjs-5.10.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b2fb1b672c8f5b55ef09f7bf89dca48ceecc06e6230bbcdb999625021f6307e2",
                "md5": "a74a952499451d5692949eaa2681762d",
                "sha256": "6b73b19658cf9fa096809b3c83c76581ee54fa57ab03cd643e01e9227d03c737"
            },
            "downloads": -1,
            "filename": "pypugjs-5.10.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a74a952499451d5692949eaa2681762d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 34199,
            "upload_time": "2024-05-22T11:00:10",
            "upload_time_iso_8601": "2024-05-22T11:00:10.530866Z",
            "url": "https://files.pythonhosted.org/packages/b2/fb/1b672c8f5b55ef09f7bf89dca48ceecc06e6230bbcdb999625021f6307e2/pypugjs-5.10.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-22 11:00:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kakulukia",
    "github_project": "pypugjs",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "pypugjs"
}
        
Elapsed time: 0.51330s