Skip to content

Instantly share code, notes, and snippets.

@cweider
Created February 20, 2012 21:09
Show Gist options
  • Save cweider/1871440 to your computer and use it in GitHub Desktop.
Save cweider/1871440 to your computer and use it in GitHub Desktop.
Ace Templates
== iframeHTML
<!doctype html>
<html>
<head>
<%= INCLUDE_CSS %>
<%= INCLUDE_JS %>
<style type="text/css" title="dynamicsyntax"></style>
</head>
<body id="innerdocbody" class="syntax" spellcheck="false">
&nbsp;
</body>
</html>
== outerScript
editorId = <%= JSON.stringify(info.id) %>;
editorInfo = parent.[<%= JSON.stringify(thisFunctionsName)%>].registry[editorId];
window.onload = function () {
window.onload = null;
setTimeout(function () {
var iframe = document.createElement("IFRAME");
iframe.scrolling = "no";
iframe.frameBorder = 0;
iframe.allowTransparency = true;
var outerdocbody = document.getElementById("outerdocbody");
outerdocbody.insertBefore(iframe, outerdocbody.firstChild);
iframe.ace_outerWin = window;
readyFunc = function () {
editorInfo.onEditorReady();
readyFunc = null;
editorInfo = null;
};
var doc = iframe.contentWindow.document;
doc.open();
var text = <%= JSON.stringify(iframeHTML.join('\n')) %>;
doc.write(text);
doc.close();
}, 0);
};
== outerHTML
<!doctype html>
<html>
<head>
<%= INCLUDE_CSS %>
<link rel="stylesheet" type="text/css" href="data:text/css,"/>
<script type="application/javascript"><%= JSON.stringify(outerScript).replace(/<\//g, '<\\/') %></script>
</head>
<body id="outerdocbody">
<div id="sidediv"><!-- --></div>
<div id="linemetricsdiv">x</div>
<div id="overlaysdiv"><!-- --></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment