Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> from django.template import Context, Template
- >>> t = Template("My name is {{ person.first_name }}.")
- >>> d = {"person": {"first_name": "Joe", "last_name": "Johnson"}}
- >>> t.render(Context(d))
- "My name is Joe."
- >>> class PersonClass: pass
- >>> p = PersonClass()
- >>> p.first_name = "Ron"
- >>> p.last_name = "Nasty"
- >>> t.render(Context({"person": p}))
- "My name is Ron."
- >>> class PersonClass2:
- ... def first_name(self):
- ... return "Samantha"
- >>> p = PersonClass2()
- >>> t.render(Context({"person": p}))
- "My name is Samantha."
- >>> t = Template("The first stooge in the list is {{ stooges.0 }}.")
- >>> c = Context({"stooges": ["Larry", "Curly", "Moe"]})
- >>> t.render(c)
- "The first stooge in the list is Larry."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement