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

Welser Muñoz
Welser Muñoz
4,447 Points

Macro Objective

Hello, I need help, I don't understand what is the question, Should I print out in lunch.py or macro?

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'
    print(user.email)
    return render_template('user.html', user=user)
templates/macro.html
{% macro hide_email(User) %}
{% endmacro %}

2 Answers

Max Hirsh
Max Hirsh
16,773 Points

From what I remember, the challenge wants you to print out and create the result in macro.html

Spyros Theodosis
Spyros Theodosis
2,080 Points

I can't solve this objective either. Do i have to modify object inside the macro ? It's very confusing especially when you are not very familiar with jinja templates.

I tried this and it works :

{% macro hiden_email(user) %} {% set list1 = user.email.split('@') %}
<p>{{ list1[0][0] }} {% for i in range(list1[0]|length-1)%} {{'*'}} {% endfor %} @{{ list1[1] }}</p> {% endmacro %}

Still not exactly what they want.Would appreciate and answer from someone whom got it right :D