I am trying to generate an iframe that displays sandboxed HTML & CSS for a teaching site. I have a partial rendered.html
that looks like this:
<html>
<head>
<link src='{{path.Join .File.Dir "style.css"}}'/>
<script src='{{path.Join .File.Dir "script.js" }}' ></script>
</head>
<body>
{{path.Join .File.Dir "body.html" | readFile }}
</body>
I then call that in the single.html
template for the relevant content section:
{{ define "main" }}
<div class="lesson-container">
<div class="md">
<div class="student-instructions">
{{path.Join .File.Dir "instructions.md" | readFile | markdownify}}</div>
</div>
<div id="tab-two-panel" class="panel">
<div class="teacher-instructions">
{{path.Join .File.Dir "teacher.md" | readFile | markdownify}}</div>
</div>
</div>
</div>
</div>
<div class="render">
<iframe srcdoc=' {{partial "rendered.html" . | safeHTML }}'></iframe>
</div>
</div>
{{ end }}
However, the iframe source only contains the <body>
element - -the <head>
and <html>
tags seem ot be stripped out. If i invoke the shortcode outside of the iframe srcdoc
attribute then the full value of the partial is expressed. Sooo… I’m not exactly sure what’s going on, but I’m pretty sure the partial is being intercepted before it completes.
I would really appreciate any suggestions! Thank you,
Matt