1

I have the dict latest_status:

{'What': 10, "Study'": 10, 'all': 10, 'to': 10, "facebook'": 10, 'has': 10, 'worth': 20, 'hurting': 10 }

I am trying to make a text cloud by doing something like this in my template:

{% for word,count in latest_status.items %}
<style="font-size:{{ count }}px"> {{ word }}</style> 
{% endfor %}

I am trying to manipulate the font size with the count from the dict but it doesn't seem to be working.

2
  • "doesn't seem to be working"? What does the output source look like, and what should it look like? Commented Mar 8, 2011 at 5:33
  • A row of words with different sizes based on the font-size. Commented Mar 8, 2011 at 5:45

1 Answer 1

5

The <style> tag is used to introduce a block (or external resource) containing style definitions. You'll want to encapsulate your text in a presentation tag of some sort--for example:

{% for word,count in latest_status.items %}
<p style="font-size:{{ count }}px;"> {{ word }}</p>
{% endfor %}
Sign up to request clarification or add additional context in comments.

3 Comments

sweet that works but is there anyway I can just return them inline? I'm not very good with html/css. Right now, every word is a new line.
Use span instead of p. Although seriously, if you're doing web development you need to know enough HTML/CSS to know the difference between block and inline elements.
@daniel Yeah, I'm kinda slowly working through the list. I have the bare minimum basics in HTML/CSS but I'm getting there! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.