xslt - Inline javascript in xsl -
i have have inline script in xsl stylesheet file problem xsl tries transform script , causes errors.
<script id="template-upload" type="text/x-tmpl"> {% (var i=0, file; file=o.files[i]; i++) { %} <tr class="template-upload fade"> <td class="preview"><span class="fade"></span></td> <td class="name"><span>{%=file.name%}</span></td> <td class="size"><span>{%=o.formatfilesize(file.size)%}</span></td> {% if (file.error) { %} <td class="error" colspan="2"><span class="label label-important">error</span> {%=file.error%}</td> {% } else if (o.files.valid && !i) { %} <td> <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div> </td> <td class="start">{% if (!o.options.autoupload) { %} <button class="btn"> <i class="icon-upload icon-white"></i> <span>start</span> </button> {% } %}</td> {% } else { %} <td colspan="2"></td> {% } %} <td class="cancel">{% if (!i) { %} <button class="btn btn-danger"> <i class="icon-ban-circle icon-white"></i> <span>cancel</span> </button> {% } %}</td> </tr> {% } %} </script>
is there way have inline script in xsl?
your javascript part not valid xml because of ampersand (&
). avoid interpretation can use cdata , disable-output-escaping avoid escaping.
<xsl:template match="/"> <script id="template-upload" type="text/x-tmpl"> <xsl:text disable-output-escaping="yes" > <![cdata[ ... ]]> </xsl:text> </script>
Comments
Post a Comment