Skip to main content

Pug4Py is a tool that allows you to integrate Pug js as a templating engine into any Python framework.

Project description

Pug4Py - Pug Templates for Python

What is pug4py?

Pug4Py is a simple script that allows you to use all the functions of Pug (NodeJs) in any python framework with the addition that you can also use the mako syntax (a popular and fast template engine for python).

Here is a small example of usage:

from pug4py.pug import Pug

pug = Pug("pug")

def say_hello():
    return "Hello World"

pug.render("example.pug", say_hello=say_hello, year="2019", author="https://github.com/multiversecoder/pug4py")

Requirements

You need Python 3.7 or later to run pug4py, node v12.10.0 and yarn

In Ubuntu, Mint and Debian you can install Requirements like this:

$ apt-get install python3 python3-pip
$ curl -sL https://deb.nodesource.com/setup_12.10.0 | sudo -E bash -
$ apt update && apt install nodejs
$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ apt update && apt install yarn

For fedora

$ dnf install python3 python3-pip
$ curl -sL https://deb.nodesource.com/setup_12.10.0 | sudo -E bash -
$ dnf update && dnf install nodejs
$ curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo
$ dnf install yarn

For other systems

- Install Python3
- Install Nodejs
- Install Yarn

Pug Installation

Pug will be installed implicitly when the Pug class is initialized and installed inside the pug4py package directory

Quick start

pug4py can be installed using pip:

$ python3 -m pip install -U pug4py

or:

$ pip install pug4py

for install pug4py from source:

$ git clone https://github.com/multiversecoder/pug4py
$ cd ./pug4py
$ pip install .

Development status

pug4py is beta software, but it has already been used in production and it has an extensive test suite.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pug4py-1.0.1.tar.gz (12.2 kB view details)

Uploaded Source

File details

Details for the file pug4py-1.0.1.tar.gz.

File metadata

  • Download URL: pug4py-1.0.1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for pug4py-1.0.1.tar.gz
Algorithm Hash digest
SHA256 834591c203e598d447431fab5cb0177c58368c620d68a90307c8f848c083e0c8
MD5 649613a927609fda0ca45ff6f89bbd3d
BLAKE2b-256 b30910cc576edb8a9217013763cabe594c8b631cef6f061094bce23ddf251f48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page