http://codereview.appspot.com/126062/diff/4001/3089
File src/com/google/caja/plugin/templates/SafeHtmlMaker.java (right):
http://codereview.appspot.com/126062/diff/4001/3089#newcode364
Line 364: emitStatement(EMIT_STATIC_HTML_PLACEHOLDER);
Why is it more complicated than:
Index: src/com/google/caja/plugin/stages/CompileHtmlStage.java
===================================================================
--- src/com/google/caja/plugin/stages/CompileHtmlStage.java
(revision 3825)
+++ src/com/google/caja/plugin/stages/CompileHtmlStage.java (working
copy)
@@ -19,7 +19,9 @@
import com.google.caja.parser.AncestorChain;
import com.google.caja.parser.css.CssTree;
import com.google.caja.parser.html.DomParser;
+import com.google.caja.parser.html.Nodes;
import com.google.caja.parser.js.Block;
+import com.google.caja.parser.quasiliteral.QuasiBuilder;
import com.google.caja.plugin.Dom;
import com.google.caja.plugin.Job;
import com.google.caja.plugin.Jobs;
@@ -85,7 +87,16 @@
Pair<Node, List<Block>> htmlAndJs = tc.getSafeHtml(
DomParser.makeDocument(null, null));
- jobs.getJobs().add(new Job(AncestorChain.instance(new
Dom(htmlAndJs.a))));
+ boolean onlyJs = false;
+ if (onlyJs) {
+ jobs.getJobs().add(new
Job(AncestorChain.instance(QuasiBuilder.substV(
+ "IMPORTS___.htmlEmitter___.emitStatic(@html);",
+ "html", Nodes.render(htmlAndJs.a)
+ ))));
+ } else {
+ jobs.getJobs().add(
+ new Job(AncestorChain.instance(new Dom(htmlAndJs.a))));
+ }
for (Block bl : htmlAndJs.b) {
jobs.getJobs().add(new Job(AncestorChain.instance(bl)));
}
http://codereview.appspot.com/126062