from django.shortcuts import render
from django.views import View

# Create your views here.

def simple(request):
    return render(request, 'tmpl/simple.html')

def guess(request) :
    context = {'zap' : '42' }
    return render(request, 'tmpl/guess.html', context)

def special(request) :
    context = {'txt' : '<b>bold</b>',
               'zap' : '42' }
    return render(request, 'tmpl/special.html', context)

def loop(request) :
    f = ['Apple', 'Orange', 'Banana', 'Lychee']
    n = ['peanut', 'cashew']
    x = {'fruits' : f, 'nuts' : n, 'zap' : '42' }
    return render(request, 'tmpl/loop.html', x)

def cond(request) :
    x = {'guess' : '42' }
    return render(request, 'tmpl/cond.html', x)

def nested(request) :
    x = {'outer' : { 'inner' : '42' } }
    return render(request, 'tmpl/nested.html', x)
    
# Call this with a parameter number
class GameView(View) :
    def get(self, request, guess) :
        x = {'guess' : int(guess) }
        return render(request, 'tmpl/cond.html', x)

# Using inheritance (extend)
class Game2View(View) :
    def get(self, request, guess) :
        x = {'guess' : int(guess) }
        return render(request, 'tmpl/cond2.html', x)


[((7, 11, 7, 46), 'django.shortcuts.render', 'render', ({(7, 18, 7, 25): 'request', (7, 27, 7, 45): '"""tmpl/simple.html"""'}, {}), "(request, 'tmpl/simple.html')", False, 'from django.shortcuts import render\n'), ((11, 11, 11, 54), 'django.shortcuts.render', 'render', ({(11, 18, 11, 25): 'request', (11, 27, 11, 44): '"""tmpl/guess.html"""', (11, 46, 11, 53): 'context'}, {}), "(request, 'tmpl/guess.html', context)", False, 'from django.shortcuts import render\n'), ((16, 11, 16, 56), 'django.shortcuts.render', 'render', ({(16, 18, 16, 25): 'request', (16, 27, 16, 46): '"""tmpl/special.html"""', (16, 48, 16, 55): 'context'}, {}), "(request, 'tmpl/special.html', context)", False, 'from django.shortcuts import render\n'), ((22, 11, 22, 47), 'django.shortcuts.render', 'render', ({(22, 18, 22, 25): 'request', (22, 27, 22, 43): '"""tmpl/loop.html"""', (22, 45, 22, 46): 'x'}, {}), "(request, 'tmpl/loop.html', x)", False, 'from django.shortcuts import render\n'), ((26, 11, 26, 47), 'django.shortcuts.render', 'render', ({(26, 18, 26, 25): 'request', (26, 27, 26, 43): '"""tmpl/cond.html"""', (26, 45, 26, 46): 'x'}, {}), "(request, 'tmpl/cond.html', x)", False, 'from django.shortcuts import render\n'), ((30, 11, 30, 49), 'django.shortcuts.render', 'render', ({(30, 18, 30, 25): 'request', (30, 27, 30, 45): '"""tmpl/nested.html"""', (30, 47, 30, 48): 'x'}, {}), "(request, 'tmpl/nested.html', x)", False, 'from django.shortcuts import render\n'), ((36, 15, 36, 51), 'django.shortcuts.render', 'render', ({(36, 22, 36, 29): 'request', (36, 31, 36, 47): '"""tmpl/cond.html"""', (36, 49, 36, 50): 'x'}, {}), "(request, 'tmpl/cond.html', x)", False, 'from django.shortcuts import render\n'), ((42, 15, 42, 52), 'django.shortcuts.render', 'render', ({(42, 22, 42, 29): 'request', (42, 31, 42, 48): '"""tmpl/cond2.html"""', (42, 50, 42, 51): 'x'}, {}), "(request, 'tmpl/cond2.html', x)", False, 'from django.shortcuts import render\n')]