问题
Does anyone know if is there any way to create javascrit templates in Genshi? I mean, I need a .js file where I can use directives like <py:for>
and so.
Any idea? Thanks!
回答1:
You can write it directly in html like this:
<script type="text/javascript">
<py:if test="func1">
/*<![CDATA[*/
function func1() {
}
/*]]>*/
</py:if>
</script>
note: code inside CDATA will be right escaped, so you can use '>','<' as usual.
来源:https://stackoverflow.com/questions/3201343/javascript-templates