Q:

TemplateSyntaxError: expected token ':', got '}'

This is my source code: 
<ul class="filebase">
        {% for file in finance %}
        <li class="filelist">
            <div class="file-author"><a href="http://127.0.0.1:5000/uploads/files/{{file. filename}}">{{ file.filename }}</a></div>
            <div class="file-body">Description: {{ file.description }}</div>
            <div class="file-date">Date posted: {{ moment(file.date).fromNow() }}</div>
            <div class="delete-file"><a href="{{ url_for('.delete_file', file_name={{ file.filename }} ) }}">Delete File</a></div><br>
        </li>
        {% endfor %}

At first, my code was working, suddenly I got an error like this:
TemplateSyntaxError: expected token ':', got '}'
Here's my Traceback (If you need):
Traceback (most recent call last):
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\flask\app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\flask\app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\flask\app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\flask\app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\flask\app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\flask_login.py", line 758, in decorated_view
    return func(*args, **kwargs)
  File "C:\Users\LouieCubero\Documents\GitHub\Flasky4\app\main\views.py", line 172, in list_of_finance
    return render_template('_filebase.html', finance = finance)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\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 "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\jinja2\environment.py", line 830, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\jinja2\environment.py", line 791, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\jinja2\environment.py", line 765, in _load_template
    template = self.loader.load(self, name, globals)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\jinja2\loaders.py", line 125, in load
    code = environment.compile(source, name, filename)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\jinja2\environment.py", line 554, in compile
    self.handle_exception(exc_info, source_hint=source)
  File "C:\Users\LouieCubero\Documents\GitHub\flasky\venv\lib\site-packages\jinja2\environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\LouieCubero\Documents\GitHub\Flasky4\app\templates\_filebase.html", line 8, in template
    <div class="delete-file"><a href="{{ url_for('.delete_file', file_name={{ file.filename }} ) }}">Delete File</a></div><br>
TemplateSyntaxError: expected token ':', got '}'

Thanks for the help!

A:

Don't do more {{}} inside of other {{}} blocks.
Here's my url_for() call:
<a href="{{ url_for('viewBlog', userid=item.userid)}}"></a>

I was getting that same error when it looked like this:
<a href="{{ url_for('viewBlog', userid={{item.userid}}) }}"></a>

Once I removed the inner {{}}, the problem went away.

