-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKG-INFO
219 lines (151 loc) · 6.42 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
Metadata-Version: 1.1
Name: pypugjs
Version: 4.2.2
Summary: PugJS syntax template adapter for Django, Jinja2, Mako and Tornado templates - copy of PyJade with the name changed
Home-page: http://github.com/matannoam/pypugjs
Author: Matan Noam Shavit
Author-email: [email protected]
License: MIT
Download-URL: https://github.com/matannoam/mypackage/pypugjs/4.2.2.tar.gz
Description: =======
PyPugJS
=======
**PyPugJS is just a fork of** `PyJade <http://github.com/syrusakbary/pyjade>`_
**with the name Jade changed to** `PugsJS <https://github.com/pugjs/pug>`_.
PyPugJS is a high performance port of PugJS for python, that converts any .pug source to the each Template-language (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
============
First, you must do::
pip install pypugjs
Or::
python setup.py install
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.
Django
------
In `settings.py`, add a `loader` to `TEMPLATES` like so:
.. code:: 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': [
# PyPugJS part: ##############################
('pypugjs.ext.django.Loader', (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
))
],
'builtins': ['pypugjs.ext.django.templatetags'], # Remove this line for Django 1.8
},
},
]
Jinja2
------
Just add `pypugjs.ext.jinja.PyPugJSExtension` as extension
.. code:: python
jinja_env = Environment(extensions=['pypugjs.ext.jinja.PyPugJSExtension'])
Mako
----
Just add `pypugjs.ext.mako.preprocessor` as preprocessor
.. code:: python
from pypugjs.ext.mako import preprocessor as mako_preprocessor
mako.template.Template(haml_source,
preprocessor=mako_preprocessor
)
Flask
-----
Just add `pypugjs.ext.jinja.PyPugJSExtension` as extension to the environment of the app
.. code:: python
app.jinja_env.add_extension('pypugjs.ext.jinja.PyPugJSExtension')
Pyramid
-------
Adjust your "your_project/__init__.py" and add the following line somewhere to in the main() function
.. code:: python
config.include('pypugjs.ext.pyramid')
Tornado Templates
-----------------
Append this after importing tornado.template
.. code:: python
from tornado import template
from pypugjs.ext.tornado import patch_tornado
patch_tornado()
(...)
Syntax
======
Generally the same as the PugJS Node.js 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:: jade
!!! 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>
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()
TESTING
=======
You must have `nose` package installed.
You can do the tests with::
./test.sh
TODOs and BUGS
==============
See: http://github.com/matannoam/pypugjs/issues
Keywords: pug pugjs template converter
Platform: UNKNOWN