pyjade
pyjade copied to clipboard
Jade doesn't accept tags with more than 2 attributes?
Hello there, I'm using PyJade with Flask and Jinja2.
Perhaps I'm missing something obvious, but PyJade throws an exception when more than two attributes are used in a tag.
For example, the following Jade code works correctly:
Example 1:
link(rel="stylesheet" href="theme.css")
Example 2:
link(type="text/css" href="theme.css")
Example 3:
link(attribute1="value1' attribute2="value2')
However, the following examples throw an exception:
Example 1:
link(rel="stylesheet" type="text/css" href="theme.css")
Example 2:
link(attribute1="value1' attribute2="value2' attribute3="value3')
For this example:
link(rel="stylesheet" type="text/css" href="theme.css")
The traceback is as follows:
Traceback (most recent call last):
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/fots/webdev/flaskage/application/views/flaskage.py", line 23, in pyjade
return render_template('index.jade')
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/flask/templating.py", line 127, in render_template
return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/jinja2/environment.py", line 830, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/jinja2/environment.py", line 791, in get_template
return self._load_template(name, self.make_globals(globals))
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/jinja2/environment.py", line 765, in _load_template
template = self.loader.load(self, name, globals)
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/jinja2/loaders.py", line 125, in load
code = environment.compile(source, name, filename)
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/jinja2/environment.py", line 554, in compile
self.handle_exception(exc_info, source_hint=source)
File "/home/fots/.virtualenv/flaskage/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/fots/webdev/flaskage/application/templates/index.jade", line 1, in template
link(rel="stylesheet" type="text/css" href="theme.css")
TemplateSyntaxError: expected token ')', got 'href'
Any help would be greatly appreciated :smile:
Cheers Fotis
How embarassing, this was a simple syntax error...
link(rel="stylesheet", type="text/css", href="theme.css")
Closing :smile:
BTW, I've recently update pyjade for support attributes without comma separation. Reopening the issue.
I'm afraid this issue still exists in v3.0.0
$ echo 'link(rel="stylesheet" type="text/css" href="site.css")' | pyjade -c html
<link rel="stylesheet"/>
@syrusakbary