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)


[((126, 161), 'django.shortcuts.render', 'render', (['request', '"""tmpl/simple.html"""'], {}), "(request, 'tmpl/simple.html')\n", (132, 161), False, 'from django.shortcuts import render\n'), ((225, 268), 'django.shortcuts.render', 'render', (['request', '"""tmpl/guess.html"""', 'context'], {}), "(request, 'tmpl/guess.html', context)\n", (231, 268), False, 'from django.shortcuts import render\n'), ((372, 417), 'django.shortcuts.render', 'render', (['request', '"""tmpl/special.html"""', 'context'], {}), "(request, 'tmpl/special.html', context)\n", (378, 417), False, 'from django.shortcuts import render\n'), ((577, 613), 'django.shortcuts.render', 'render', (['request', '"""tmpl/loop.html"""', 'x'], {}), "(request, 'tmpl/loop.html', x)\n", (583, 613), False, 'from django.shortcuts import render\n'), ((672, 708), 'django.shortcuts.render', 'render', (['request', '"""tmpl/cond.html"""', 'x'], {}), "(request, 'tmpl/cond.html', x)\n", (678, 708), False, 'from django.shortcuts import render\n'), ((783, 821), 'django.shortcuts.render', 'render', (['request', '"""tmpl/nested.html"""', 'x'], {}), "(request, 'tmpl/nested.html', x)\n", (789, 821), False, 'from django.shortcuts import render\n'), ((973, 1009), 'django.shortcuts.render', 'render', (['request', '"""tmpl/cond.html"""', 'x'], {}), "(request, 'tmpl/cond.html', x)\n", (979, 1009), False, 'from django.shortcuts import render\n'), ((1151, 1188), 'django.shortcuts.render', 'render', (['request', '"""tmpl/cond2.html"""', 'x'], {}), "(request, 'tmpl/cond2.html', x)\n", (1157, 1188), False, 'from django.shortcuts import render\n')]