Skip to main content

A python implementation of the famous js template engine. doT.js.

Project description

doT.py

A python implementation of the famous js template engine. doT.js. http://olado.github.io/doT/index.html. It do excetly the same thing as doT.js except written in python. Thus, it can be used in python web framework.

doT.py compile the template to a pure javascript function in server side; therefore client side can evaluate the template later without any dependency. Which means it saves the time for client to load template engine and to load template file. In short, doT.py allows using client side template tech without include a template engine in client side.

Installation

pip install doT.py

Here is an example:

Use client side template

<html>
<!-- load template engine -->
<script type="text/javascript" src="doT.js"></script>
<div id="container">
<script type="text/javascript">
     // Compile template function
     var tempFn = doT.template("<h1>Here is a sample template {{=it.foo}}</h1>");
     var resultText = tempFn({foo: 'with doT'});
     document.getElementById('container').innerHtml = resultText;
</script>
</html>

Use doT.py, you write:

<html>
<!-- without loading template engine -->
<div id="container">
<script type="text/javascript">
     // Compile template function
     var tempFn = {{ js_template('<h1>Here is a sample template {{=it.foo}}</h1>') }};
     var resultText = tempFn({foo: 'with doT'});
     document.getElementById('container').innerHtml = resultText;
</script>
</html>

it will automatically compiled to

<html>
<!-- without loading template engine -->
<div id="container">
<script type="text/javascript">
     // Compile template function
     var tempFn = function anonymous(it) { var out='"<h1>Here is a sample template '+(it.foo)+'</h1>"';return out; };
     var resultText = tempFn({foo: 'with doT'});
     document.getElementById('container').innerHtml = resultText;
</script>
</html>

Django Support:

Jinja2 Support:

Commandline Support:

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

dot-js-py-0.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

dot_js_py-0.0.1-py2.py3-none-any.whl (4.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dot-js-py-0.0.1.tar.gz.

File metadata

  • Download URL: dot-js-py-0.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.6 Darwin/22.1.0

File hashes

Hashes for dot-js-py-0.0.1.tar.gz
Algorithm Hash digest
SHA256 62e5a75c14a1fa3daf1d7eca007307c675afa8045b176fe7a1fab97155fe5a83
MD5 bcd6a204a31e134d11a59997d03582f9
BLAKE2b-256 1b88b708f74288cc2e689521ec65ead5ada2de399fd3768d7a08c3c6c86264af

See more details on using hashes here.

File details

Details for the file dot_js_py-0.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: dot_js_py-0.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.6 Darwin/22.1.0

File hashes

Hashes for dot_js_py-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 317bb2062b4aec7a8a07457d10b85ec6464fb6f106aca7b8e8a79590a1ca7f64
MD5 bbcd30db2e9de8586e55df5d93a08e36
BLAKE2b-256 ba2fd7d072729db3279a453ae9a01e4232397bc586d4cd245ba5c41b970b9a05

See more details on using hashes here.

Supported by

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