Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 46 committers (2.2%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (6.0%) to scientific vocabulary
Repository
Jade template system for Django, Jinja2 and Mako
Basic Info
Statistics
- Stars: 696
- Watchers: 21
- Forks: 121
- Open Issues: 101
- Releases: 0
Metadata Files
README.md
PyJade 
PyJade 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).
UTILITIES
To simply output the conversion to your console:
console
pyjade [-c django|jinja|mako|tornado] input.jade [output.html]
or, alternatively:
console
pyjade [-c django|jinja|mako|tornado] [-o output.html] < input.jade
To convert directly inside a python script:
``` import pyjade jadetext = '''!!! 5 html head body foo bar! ''' print pyjade.simpleconvert(jade_text)
```
INSTALLATION
First, you must do:
console
pip install pyjade
Or:
console
python setup.py install
Now simply name your templates with a .jade extension and this jade compiler
will do the rest. Any templates with other extensions will not be compiled
with the pyjade compiler.
Django
For Django 1.9
In settings.py, add a loader to TEMPLATES like so:
python
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request'
],
'loaders': [
# PyJade part: ##############################
('pyjade.ext.django.Loader', (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
))
],
'builtins': ['pyjade.ext.django.templatetags'],
},
},
]
For Django 1.8
In settings.py, add a loader to TEMPLATES like so:
python
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request'
],
'loaders': [
# PyJade part: ##############################
('pyjade.ext.django.Loader', (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
))
],
},
},
]
Or, in Django 1.7 or earlier:
In settings.py, modify TEMPLATE_LOADERS like:
python
TEMPLATE_LOADERS = (
('pyjade.ext.django.Loader',(
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)),
)
Jinja2
Just add pyjade.ext.jinja.PyJadeExtension as extension:
python
jinja_env = Environment(extensions=['pyjade.ext.jinja.PyJadeExtension'])
Mako
Just add pyjade.ext.mako.preprocessor as preprocessor:
python
from pyjade.ext.mako import preprocessor as mako_preprocessor
mako.template.Template(jade_source,
preprocessor=mako_preprocessor
)
Flask
Just add pyjade.ext.jinja.PyJadeExtension as extension to the environment of the app::
python
app.jinja_env.add_extension('pyjade.ext.jinja.PyJadeExtension')
Pyramid
Adjust your "yourproject/init_.py" and add the following line somewhere to in the main() function:
python
config.include('pyjade.ext.pyramid')
Tornado Templates
Append this after importing tornado.template
```python from tornado import template from pyjade.ext.tornado import patchtornado patchtornado()
(...) ```
Syntax
Exactly the same as the Jade Node.js module (except of cases, which are not implemented) https://github.com/visionmedia/jade/blob/master/README.md
Example
This code:
jade
!!! 5
html(lang="en")
head
title= pageTitle
script(type='text/javascript').
if (foo) {
bar()
}
body
h1.title Jade - node template engine
#container
if youAreUsingJade
p You are amazing
else
p Get on it!
Converts to:
html
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{pageTitle}}</title>
<script type='text/javascript'>
if (foo) {
bar()
}
</script>
</head>
<body>
<h1 class="title">Jade - node template engine</h1>
<div id="container">
{%if youAreUsingJade%}
<p>You are amazing</p>
{%else%}
<p>Get on it!</p>
{%endif%}
</div>
</body>
</html>
Register filters
If you want to register a function as a filter, you only have to
decorate the function with pyjade.register_filter("filter_name")
```python import pyjade
@pyjade.register_filter('capitalize') def capitalize(text,ast): return text.capitalize() ```
Using templatetags (and any feature of the compiled-to language)
Using Django and crispy-forms as an illustrative example but the information can be generalized.
If you need to use templatetags, you can use Jade's syntax for rendering code:
jade
- load crispy_forms_tags
- crispy form
This will compile into
html
{% load crispy_forms_tags %}
{% crispy form %}
If you have any trouble with this feature, or there's some feature of your template language that is being misinterpreted when using this syntax, you can also do something like this:
jade
| {% load crispy_forms_tags %}
| {% crispy form %}
This will compile into the same Django template snippet.
TESTING
You must have nose package installed.
You can do the tests with
console
./test.sh
TODOs and BUGS
See: http://github.com/syrusakbary/pyjade/issues
Owner
- Name: Syrus Akbary
- Login: syrusakbary
- Kind: user
- Location: San Francisco, CA
- Company: @wasmerio
- Website: http://syrusakbary.com
- Repositories: 141
- Profile: https://github.com/syrusakbary
Entrepreneur. Mathematician. @wasmerio CEO (YC S19). @GraphQL-Python creator. Author of Graphene, pyjade, promises (py) and other cool stuff... 😄
GitHub Events
Total
- Watch event: 1
- Issue comment event: 1
Last Year
- Watch event: 1
- Issue comment event: 1
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Syrus Akbary | me@s****m | 91 |
| Nathan Hwang | t****f@g****m | 8 |
| Charles | p****h@g****m | 7 |
| Thomas | e****y@h****t | 6 |
| Thomas B Homburg | t****s@h****k | 5 |
| Michael Floering | m****g@g****m | 4 |
| Pavel | h****t@g****m | 4 |
| Ben Cook | b@b****a | 4 |
| Dustin Farris | d****n@d****m | 4 |
| Christopher Currie | c****e@i****m | 3 |
| Ed Singleton | s****d@g****m | 3 |
| Chris Haines | c****s@g****m | 3 |
| Jelte Fennema | g****h@j****l | 3 |
| Jesús Espino | j****o@k****t | 2 |
| Joshua Ma | me@j****m | 2 |
| Reorx | n****x@g****m | 2 |
| rockerzz | r****z@g****m | 2 |
| hellysmile | h****e@g****m | 1 |
| Yang Zhang | y****g@g****m | 1 |
| Tomasz Walotek | t****k@g****m | 1 |
| Todd Wolfson | t****d@t****m | 1 |
| Damien Churchill | d****l@u****t | 1 |
| Henrique Leal | h****l@c****m | 1 |
| Joshua Gao | j****6@p****u | 1 |
| Sebastian Audet | S****t@C****m | 1 |
| h-hirokawa | h****a@r****p | 1 |
| john | j****n@b****e | 1 |
| Árni St. Sigurðsson | a****g@t****m | 1 |
| Adam Szatrowski | a****i@w****m | 1 |
| The Gitter Badger | b****r@g****m | 1 |
| and 16 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 65
- Total pull requests: 37
- Average time to close issues: over 1 year
- Average time to close pull requests: over 1 year
- Total issue authors: 57
- Total pull request authors: 25
- Average comments per issue: 2.26
- Average comments per pull request: 1.38
- Merged pull requests: 6
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- smaudet (3)
- glassresistor (3)
- cclauss (2)
- pykong (2)
- wolfgang42 (2)
- kakulukia (2)
- amrullah (1)
- emiguelt (1)
- ruivieira (1)
- dbykadorov (1)
- sarincasm (1)
- degustator (1)
- theskillwithin (1)
- gummz (1)
- good-idea (1)
Pull Request Authors
- paradoxxxzero (5)
- blx (3)
- tdamsma (2)
- char101 (2)
- smaudet (2)
- zeraien (2)
- bowbahdoe (2)
- hmleal (2)
- beltiras (1)
- mateucs9 (1)
- frgtn (1)
- adam410 (1)
- ghost (1)
- alonisser (1)
- vladh (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 1,736 last-month
- Total docker downloads: 67
-
Total dependent packages: 4
(may contain duplicates) -
Total dependent repositories: 310
(may contain duplicates) - Total versions: 30
- Total maintainers: 2
pypi.org: pyjade
Jade syntax template adapter for Django, Jinja2, Mako and Tornado templates
- Homepage: http://github.com/syrusakbary/pyjade
- Documentation: https://pyjade.readthedocs.io/
- License: MIT
-
Latest release: 4.0.0
published over 10 years ago
Rankings
Maintainers (1)
pypi.org: axado.pyjade
Jade syntax template adapter for Django, Jinja2, Mako and Tornado templates
- Homepage: http://github.com/syrusakbary/pyjade
- Documentation: https://axado.pyjade.readthedocs.io/
- License: MIT
-
Latest release: 5.0.0
published over 8 years ago
Rankings
Maintainers (1)
Dependencies
- django *
- jinja2 *
- mako *
- six *
- tornado *
- six *