Example #1
0
def htmlify_ajax(request):
    if request == 'POST' or request.is_ajax():
        form = HtmlifyForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            original_code = form.cleaned_data['code']
            html_code = htmlify_code(original_code)
        else:
            return HttpResponse('Something went wrong...')
        return HttpResponse(html_code)
    return HttpResponse('bla')
Example #2
0
def htmlify_ajax(request):
    if request == 'POST' or request.is_ajax():
        form = HtmlifyForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            original_code = form.cleaned_data['code']
            encoding = form.cleaned_data['encoding']
            html_code = htmlify_code(original_code, encoding)
        else:
            return HttpResponse('Something went wrong...')
        return HttpResponse(html_code)
    return HttpResponse('bla')
Example #3
0
def htmlify(request):
    context = RequestContext(request)
    if request.method == 'GET':
        form = HtmlifyForm()
    elif request.method == 'POST':
        form = HtmlifyForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            original_code = form.cleaned_data['code']
            html_code = htmlify_code(original_code)
            context.update({'htmlified': html_code,
                            'to_htmlify': original_code})
    context.update({'form': form})
    return render_to_response('htmlify.html', context)
Example #4
0
def htmlify(request):
    context = RequestContext(request)
    if request.method == 'GET':
        form = HtmlifyForm()
    elif request.method == 'POST':
        form = HtmlifyForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            original_code = form.cleaned_data['code']
            encoding = form.cleaned_data['encoding']
            html_code = htmlify_code(original_code, encoding)
            context.update({'htmlified': html_code,
                            'to_htmlify': original_code})
    context.update({'form': form})
    return render_to_response('htmlify.html', context)