Created
December 2, 2009 20:46
-
-
Save hoffrocket/247557 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ScriptFilter extends JsCmd { | |
def content:NodeSeq | |
override def fixHtml(uid: String, content: NodeSeq): String = { | |
def xform(in: NodeSeq): NodeSeq = in flatMap { | |
case e: Elem if e.label == "script" => NodeSeq.Empty | |
case e: Elem => Elem(e.prefix, e.label, e.attributes, e.scope, xform(e.child) :_*) | |
case g: Group => xform(g.child) | |
case x => x | |
} | |
AltXML.toXML(Group(xform(S.session.map(s => s.fixHtml(s.processSurroundAndInclude("JS SetHTML id: " + uid, content))).openOr(content))),false, true, S.ieMode).encJs | |
} | |
abstract override val toJsCmd:String = super.toJsCmd + (for(script <- content \\ "script") yield script.text).toList.mkString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment