@require_GET
@allow_CORS_GET
@xframe_options_exempt
@process_document_path
def code_sample(request, document_slug, document_locale, sample_name):
 if (not re.search(config.KUMA_WIKI_IFRAME_ALLOWED_HOSTS, request.build_absolute_uri())):
  raise PermissionDenied
 document = get_object_or_404(Document, slug=document_slug, locale=document_locale)
 job = DocumentCodeSampleJob(generation_args=[document.pk])
 data = job.get(document.pk, sample_name)
 data['document'] = document
 return render(request, 'wiki/code_sample.html', data)

@ require_GET @ allow_CORS_GET @ xframe_options_exempt @ process_document_path def code_sample ( request , document_slug , document_locale , sample_name ) : if ( not re . search ( config . KUMA_WIKI_IFRAME_ALLOWED_HOSTS , request . build_absolute_uri ( ) ) ) : raise PermissionDenied document = get_object_or_404 ( Document , slug = document_slug , locale = document_locale ) job = DocumentCodeSampleJob ( generation_args = [ document . pk ] ) data = job . get ( document . pk , sample_name ) data [ 'document' ] = document return render ( request , 'wiki/code_sample.html' , data )
extract a code sample from a document and render it as a standalone html document .