10

Have two files in a Flask application:

base.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="../static/main.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.1.1/css/bootstrap.min.css"> <title>Title</title> </head> <body> <div id="content"> {% marker "content" %} </div> </body> </html> 

upload.html, which extends base.html

{% extends "base.html" %} {% block "content " %} <title>Upload new File</title> <h1>Upload new File</h1> <form action="" method=post enctype=multipart/form-data> <p><input type=file name=file> <input type=submit value=Upload> </form> {% endblock %} 

I'm calling the latter in a view: return render_template('upload.html' ), and I'm getting an error:

jinja2.exceptions.TemplateSyntaxError TemplateSyntaxError: expected token 'name', got 'string' 
1
  • 2
    {% block content %}? instead of "content", as it's a sort of identifier? Commented Apr 5, 2013 at 0:56

1 Answer 1

8

The issue is that {% block "content" %} should be {% block content %} - the block's name should not be quoted.

In addition the marker construct in your layout.html is not a valid Jinja2 tag - it should be {% block content %}{% endblock %}.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.