Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Does anyone have a good resource for where to get the basics of HTML down?

I am not sure if this is requiring HTML or Javascript or Python?

lunch.py
from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    class User:
        email = None
    user = User()
    user.email = 'kenneth@teamtreehouse.com'
    return render_template('user.html', user=user)
templates/macro.html
{% macro hide_email(User) %}
  to_string = str(User.email)
  {% for char in to_string %}
    {% if char == @}
      break
    {%endif %}
  {% endfor %}
{% endmacro %}

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,454 Points

To solve this challenge you need to use HTML plus the jinja2 syntax specific to the templating system used the flask environment. Jinja2 supplements the HTML language by adding template tags, marked by the curly braces {}, that are parsed and evaluated before the code is passed to the HTML processor. This preprocessing allows the jinja2 code to be converted to HTML. The jinja2 documentations has many help details. The macros section is particularly useful.

PROTIP: make note of the minus signs strategically placed inside the template tag markers: {%- and -%} instead of {% and %}. these mean do NOT insert whitespace between elements. See Whitespace Control.

Without white space control, your template tags, for-loops and all, would have to be all placed adjacently on the same line.

Steven Parker
Steven Parker
231,271 Points

What a question to ask ... here! Treehouse has many HTML courses and workshops, including Introduction to HTML and CSS, HTML and How to Make a Website.

But your code snippet is all (intermediate-level) Python, except for the file being passed to render_template as an argument.